fromNullable<T> function

Option<T> fromNullable<T>(
  1. T? value
)

Returns an Option that returns Some or None, depending on whether it is null or not.

expect(fromNullable(123), some(123));
expect(fromNullable(null), none());

Implementation

Option<T> fromNullable<T>(T? value) => value != null ? some(value) : kNone;