call | -> | update |
Use a Proc as an observable. |
Operator for Proc#compose and Integer#times_collect/of.
a = lambda { |x| x + 4 } b = lambda { |y| y / 2 } (a * b).call(4) #=> 6 (b * a).call(4) #=> 4
Returns a new proc that is the functional compostion of two procs, in order.
a = lambda { |x| x + 4 } b = lambda { |y| y / 2 } a.compose(b).call(4) #=> 6 b.compase(a).call(4) #=> 4
Build a hash out of a Proc.
l = lambda { |s| s.a = 1 s.b = 2 s.c = 3 } l.to_h #=> {:a=>1, :b=>2, :c=>3}
Translates a Proc into an OpenObject. By droping an OpenObject into the Proc, the resulting assignments incured as the procedure is evaluated produce the OpenObject. This technique is simlar to that of MethodProbe.
p = lambda { |x| x.word = "Hello" } o = p.to_openobject o.word #=> "Hello"
NOTE The Proc must have an arity of one —no more and no less.