Hi, all,
Is it possible to use -> as a method name in Ruby?
This code:
class A
def ->(arg)
puts arg
end
end
foo = A.new
foo -> "dummy_argument"
Produces:
~/test2.rb:2: syntax error, unexpected '>', expecting '\n' or
';'
def ->(arg)
^
~/test2.rb:5: syntax error, unexpected kEND, expecting $end
But if I substitute the '->' with '>>', the program works and I get:
dummy_argument
Any idea what's going on here?
Running ruby 1.8.6 on Debian unstable.
Many thanks in advance, greetings,
Andrew Green