How do I use Ruby's new lambda syntax? -


ruby has lambda syntax, can use -> symbol:

a = 0 new  -> { < 5 }     puts    += 1 end 

this works well, when try this:

match "/", to:  -> { |e| [404, {}, ["hello! micro rack app"]] }, via: [:get] match( "/", to:  -> { |e| [404, {}, ["hello! micro rack app"]] }, via: [:get] ) match( "/", { to:  -> { |e| [404, {}, ["hello! micro rack app"]] }, via: [:get] }) 

all of return same syntax error:

$ ruby -c -e 'match( "/", to:  -> { |e| [404, {}, ["hello! micro rack app"]] }, via: [:get] )' -e:1: syntax error, unexpected '|' match( "/", to:  -> { |e| [404, {}, ["hello! mi... 

am missing something?

i think new syntax should be

match "/", to:  ->(e) { [404, {}, ["hello! micro rack app"]] }, via: [:get] 

Comments

Popular posts from this blog

SPSS keyboard combination alters encoding -

Add new record to the table by click on the button in Microsoft Access -

javascript - jQuery .height() return 0 when visible but non-0 when hidden -