lib/mangrove/option.rb in mangrove-0.8.1 vs lib/mangrove/option.rb in mangrove-0.9.1

- old
+ new

@@ -16,9 +16,23 @@ sealed! interface! InnerType = type_member + class << self + extend ::T::Sig + + sig { type_parameters(:InnerType).params(nilable: T.nilable(T.type_parameter(:InnerType))).returns(Mangrove::Option[T.type_parameter(:InnerType)]) } + def from_nilable(nilable) + case nilable + when NilClass + Mangrove::Option::None.new + else + Mangrove::Option::Some.new(nilable) + end + end + end + # Option::Some class Some extend T::Sig extend T::Generic extend T::Helpers