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
Post a Comment