Class: Qo::Branches::MonadicElseBranch

Inherits:
Branch
  • Object
show all
Defined in:
lib/qo/branches/monadic_else_branch.rb

Overview

Based on the else branch, except deals with monadic values by attempting to extract the value before yielding to the given function on a match:

Matcher.new.call(Some[1]) { |m|
  m.else { |v| v + 2 }
}
# => 3

Author:

  • baweaver

Since:

  • 1.0.0

Constant Summary

Constants inherited from Branch

Branch::UNMATCHED

Instance Attribute Summary

Attributes inherited from Branch

#name

Instance Method Summary collapse

Methods inherited from Branch

create, #create_matcher, #default?

Constructor Details

#initialize(destructure: false, extractor: :value) ⇒ MonadicElseBranch

Returns a new instance of MonadicElseBranch

Since:

  • 1.0.0



16
17
18
19
20
21
22
23
# File 'lib/qo/branches/monadic_else_branch.rb', line 16

def initialize(destructure: false, extractor: :value)
  super(
    name: 'else',
    destructure: destructure,
    extractor: extractor,
    default: true,
  )
end