Skip to content

v1.4.0

Compare
Choose a tag to compare
@flash-gordon flash-gordon released this 20 Jul 08:19
v1.4.0
e2b762a

Added

  • Unit destructures to an empty array (flash-gordon)
  • When .value! called on a Failure value the error references to the value (rewritten + flash-gordon)
    begin
      Failure("oops").value!
    rescue => error
      error.receiver # => Failure("oops")
    end
  • Result#alt_map for mapping failure values (flash-gordon)
    Failure("oops").alt_map(&:upcase) # => Failure("OOPS")
  • Try#recover recovers from errors (flash-gordon)
    error = Try { Hash.new.fetch(:missing) }
    error.recover(KeyError) { 'default' } # => Try::Value("default")
  • Maybe#filter runs a predicate against the wrapped value. Returns None if the result is false (flash-gordon)
    Some(3).filter(&:odd?)  # => Some(3)
    Some(3).filter(&:even?) # => None
    # no block given
    Some(3 == 5).filter     # => None
  • RightBiased#| is an alias for #or (flash-gordon)
    None() | Some(6) | Some(7) # => Some(6)
    Failure() | Success("one") | Success("two") # => Success("one")

Fixed

  • Do notation preserves method visibility (anicholson + flash-gordon)

Changed

  • Coercing nil values to None with Some#fmap is officially deprecated. (flash-gordon)
    Switch to Some#maybe when you expect nil.
    This behavior will be dropped in 2.0 but you can opt-out of warnings for the time being
    Dry::Monads::Maybe.warn_on_implicit_nil_coercion false
  • Minimal Ruby version is 2.6

Compare v1.3.5...v1.4.0