optional
optional copied to clipboard
Example in the readme does not seem to compile
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?