I want to create a new lambda with no arguments from the lambda taking it.
Say I have
irb(main):001:0> f1 = lambda { |p| p } => #<Proc: 0x00000001045190@ (irb):1 (lambda)> irb(main):002:0> f1.call(2) => 2
and now I
irb(main):003:0> f2 = lambda { f1.call(2) } => #<Proc: 0x00000000f620e8@ (irb):3 (lambda)> irb(main):004:0> f2.call => 2
but I do not want to create a lambda around the first, but I want to "substitute" a parameter for it or something like that.
Maybe if we have a call , there is some kind of magic that does the same thing as the call, but returns a lambda, except for the actual code call:
f2 = f1.some_magic(2) f2.call => 2
PS Sorry, if this question is dumb, this functional material is difficult for me to understand sometimes.
PPS Found this section on ruby-forum.com, and it seems I want to do the same without any extra overhead.
source share