optional icon indicating copy to clipboard operation
optional copied to clipboard

Example in the readme does not seem to compile

Open AndrejMitrovic opened this issue 1 year ago • 0 comments

Hi,

I'm trying this out with DMD v2.102.0 with the Includes a generic or range algorithm example on https://github.com/aliak00/optional#features:

import optional;

void main() {
    auto a = some(3);
    auto b = a.or(7);
}
lib/optional/source/optional/or.d(152,13): Error: expected return type of `int`, not `Optional!int`:
lib/optional/source/optional/or.d(150,13):        Return type of `int` inferred here.
lib/optional/source/optional/or.d(189,17): Error: template instance `optional.or.or!(Optional!int, int).or.or!(elseValue, Optional!int)` error instantiating
test.d(5,18):        instantiated from here: `or!(Optional!int, int)`

This works however:

    auto a = some(3);
    auto b = a.or(some(7));

Maybe just some() was missing?

AndrejMitrovic avatar Jun 26 '23 09:06 AndrejMitrovic