Charlton Wang wrote:

> I'm seeing two odd behaviours with using lambdas:
> 
> 1. It seems as though having a lambda as a function argument with a
> block causes a syntax error. It can be mitigated by adding a semicolon
> or by using parentheses
> 
> def foo(rest)
>    puts rest.inspect
>    yield
> end
> 
> 
> # 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' }
#<Proc:0x02b14a5c@(irb):6>
in block
    ==>nil