metaprogramming - Any way to implement implicit "it" in Ruby blocks, like in Lisp? -
apparently in lisp when write block/lambda without parameters, word "it" takes value passed in block.
this seems elegant; it; want in ruby. there way make work?
3.times { p }
should print "0 1 2"
obviously eval block in context included method_missing returned value :it (or maybe def object#it). value should return? if "yield 42" block, , block declared without parameters, there general way recover value 42?
(the original version of question asked c#, hence comments. apparently c# doesn't have lisp does.)
nope, don't think so.
ruby has self
it's not going out here
you have do
3.times { |n| p n }
Comments
Post a Comment