opCast cannot implicitly convert a.opCast of type X to Y
aliak
something at something.com
Wed Feb 14 23:46:30 UTC 2018
On Wednesday, 14 February 2018 at 15:14:24 UTC, Meta wrote:
>
> I think the best way to do this is to implement `map` for your
> optional type.
>
> Optional!U map(U, alias f)()
> {
> return empty? no!U : some!U(f(t));
> }
>
> Optional!int a = 3;
> auto b = a.map!(v => cast(float)v);
> assert(is(typeof(b) == Optional!float));
Ooh yes, of course! Thank you :)
More information about the Digitalmars-d-learn
mailing list