Method: LambdaDriver::Composable#compose
- Defined in:
-
lib/lambda_driver/composable.rb,
lib/lambda_driver/composable.rb
Returns new lambda which composed self and given function. A composed proc called with args, executes ‘self.(g(*args)).
f = lambda{|x| x.to_s }
g = lambda{|y| y.length }
h = f compose g
h.(:hoge) # => 4
This method is aliased as ‘<<`.
f << g # => f.compose(g)
16 17 18 19 20 |
# File 'lib/lambda_driver/composable.rb', line 16 def compose(g) lambda{|*args| self.to_proc.call(g.to_proc.call(*args)) } end |