There are different ways to define a lambda or proc in ruby:
with lambda
-keyword
test = lambda do |arg|
puts arg
end
with the lambda literal ->
(since ruby 1.9.1)
test = -> (arg) do
puts arg
end
with the proc
keyword (which defines a lambda that does not test the given number of arguments):
test = lambda do |arg|
puts arg
end
And there are different ways to call them:
call
(we prefer this)
test.call('hello world')
Square brackets (could easily be mistaken for a hash)
test['hello world']
.()
(weird, isn't it?)
test.('hello world')