Parser bug?

So I was playing around, and decided that I wanted to define a method
that ended in ?, but also happened to not have anything but an ending,
.

So I did this:

def ?()
end

I got a syntax error, not very surprising. The interesting bit was
what syntax error I got:

% ruby < def ?()
heredoc> end
heredoc> HERE
-:1: parse error, unexpected tINTEGER
def ?()
^

Obviously a ‘)’ is not an integer token. Thoughts? Comments? Insults? Is
this really a bug?

the ? operator takes an ascii symbol and returns numerical value for it
(namely integer)

lopex

Marcin MielżyÅ?ski wrote:

the ? operator takes an ascii symbol and returns numerical value for it
(namely integer)

at parse time of course…

lopex

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs