nlkl / Optional

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

Optional.Collection nuget package v.1.1.0 misses Values and Exceptions extension methods #45

Closed manuel-ornato closed 6 years ago

manuel-ornato commented 6 years ago

Hi,

It seems Optional.Collection misses Values and Exceptions extension methods in Nuget package 1.1.0.

By the way, I was wondering what is the best way of accessing the Exception property of an Option<T,TException>? Is it opt.Match(v => Option.None<TException>(), ex => ex.Some())? Maybe an extension method (ToException ?) that does that would be a fine addition to the lib. An ExceptionOrFailure in unsafe might also be provided.

I have to say this lib changed my programmer's life! Thanks a lot for your work.

Manuel

nlkl commented 6 years ago

Hi Manuel,

Thank you for the nice words and your interest in the project.

Regarding the .Values() and .Exceptions() extension methods, these are not included in Optional.Collections, but part of the upcoming v4 release, which directly includes the most important functionality from Optional.Collections (which in turn will not be supported in the future). You can grab the pre-release on Nuget - I have been using it for some time already without any problems, so it should be rather stable (and will be fully released in the not-too-distant future).

Currently, .Match(...) is the preferred way to get the exceptional value. I am, however, always considering ways improve usability of the library, and streamlining the ways in which you can work with exceptional values is definitely on the roadmap.

Have a great day.

Best regards, / Nils

nlkl commented 6 years ago

(also see https://github.com/nlkl/Optional/issues/47 )