Ruby has lambda syntax, so I can use the ->
symbol:
a = 0
new -> { a < 5 } do
puts a
a += 1
end
This works very well, but when I try to do this:
match "/", to: -> { |e| [404, {}, ["Hello! I am micro rack app"]] }, via: [:get]
match( "/", to: -> { |e| [404, {}, ["Hello! I am micro rack app"]] }, via: [:get] )
match( "/", { to: -> { |e| [404, {}, ["Hello! I am micro rack app"]] }, via: [:get] })
all of the return the same syntax error:
$ ruby -c -e 'match( "/", to: -> { |e| [404, {}, ["Hello! I am micro rack app"]] }, via: [:get] )'
-e:1: syntax error, unexpected '|'
match( "/", to: -> { |e| [404, {}, ["Hello! I am mi...
Am I missing something?
I think that new syntax should be
It seems you are mixing
->
andlambda
syntaxAnd
Personally I would use the 'lambda' syntax as it is more rubyish.
I think the syntax should be like this.