Class: Qo::Branches::MonadicElseBranch
- 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
Constant Summary
Constants inherited from Branch
Instance Attribute Summary
Attributes inherited from Branch
Instance Method Summary collapse
-
#initialize(destructure: false, extractor: :value) ⇒ MonadicElseBranch
constructor
A new instance of MonadicElseBranch.
Methods inherited from Branch
create, #create_matcher, #default?
Constructor Details
#initialize(destructure: false, extractor: :value) ⇒ MonadicElseBranch
Returns a new instance of MonadicElseBranch
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 |