Using Object(s) Do ...
Join the DZone community and get the full member experience.Join For Free
A little meta-hack that allows one to temporarily assign one or more objects into the scope of a block. My thanks to vinterbleg for optimizing it.
def using (*args) yield *args endFor (a rather half-assed) example:
>> using [10,20,30], 40 do |x,y| >> x << y if y.is_a? Fixnum >> puts x.to_s >> end 10203040 => nil
Opinions expressed by DZone contributors are their own.