nlkl / Optional

A robust option type for C#
MIT License
903 stars 73 forks source link

Add implicit casts from a value to Option types #70

Closed declard closed 5 years ago

declard commented 5 years ago

Provides an implicit cast from of any type T to a corresponding Option of T

Useful in scenario like this:

Option<int> LovelyFunction()
{
    DoSomething();
    DoSomethingElse();
    return 42;
}
nlkl commented 5 years ago

Hi!

Thanks for your interest in Optional and this PR.

This has been considered previously, where we decided not to proceed: https://github.com/nlkl/Optional/issues/53

Once nullable reference types land, I might reconsider an implicit cast fromT? to Option<T>.

/ Nils