From: mental@... Date: 2005-12-16T07:44:56+09:00 Subject: Re: Assigning a block to a variable in Ruby Quoting ajmayo@my-deja.com: > I am new to Ruby and curious as to how you emulate the following > Javascript snippet > (example in Windows, hence the call to Echo) > > var a = function(p) {WScript.Echo(p)} Ruby: a = lambda { |p| WScript.Echo(p) } (assuming Ruby had an appropriate WScript.Echo) You'd need to call that like: a.call("something") instead of a("something") though. > It is also unclear, how, then, I pass down a block as an argument > and then in turn pass it again to a child routine. If you prefix the last argument in a method definition or call with &, then it'll be used to pass/receive a block. def f(arg, &block) g(arg, &block) end # call it: f(1) { ... } You can employ a lambda (as illustrated above) as a block using this & notation too. -mental