From: Charlton Wang Date: 2008-12-07T11:14:22+09:00 Subject: Re: Ruby 1.8.7 Lambas: syntax and scoping issue (are these b Sorry, you lost me with your example. My block is being bound with do/end rather than {}. In your examples, you're using {} which has tighter binding and the syntax error is expected. foo 'hello' do puts 'in block'; end works just find but this isn't the same as what I'm asking. I'm binding the lambda function as a hash value. Or...maybe I'm missing something obvious. Charlton William James wrote: > Charlton Wang wrote: > >> >> >> # fails syntax error >> foo :parm1=>1, :parm2=>lambda { puts "lambda" } do >> puts "In bar block" >> end > > The syntax is wrong whether or not you are passing > a Proc object as an argument. > > def foo(rest) > puts rest.inspect > yield > end > ==>nil > foo 'hello' { puts 'in block' } > SyntaxError: compile error > (irb):5: syntax error > foo 'hello' { puts 'in block' } > ^ > (irb):5: syntax error > from (irb):5 > from :0 > foo( 'hello' ){ puts 'in block' } > "hello" > in block > ==>nil > foo( proc{p "I'm neither sheep nor lambda."} ){ puts 'in block' } > # > in block > ==>nil -- Posted via http://www.ruby-forum.com/.