Hi --

On Tue, 13 Aug 2002, Dossy wrote:

> On 2002.08.13, ts <decoux / moulon.inra.fr> wrote:
> > >>>>> "D" == Dossy  <dossy / panoptic.com> writes:
> >
> > D> There IS no method #1? defined.
> >
> >  in `1?true:false' `1' is interpreted as a Fixnum
>
> Ahh.  But then, constants aren't method calls, so
> why doesn't something like this work:
>
>     irb(main):002:0> FalseClass ? 0 : 1
>     0
>
> No surprise, right?  Then why does this happen:
>
>     irb(main):003:0> FalseClass?0:1
>     SyntaxError: compile error
>     (irb):3: parse error
>     FalseClass?0:1
>                  ^
>             from (irb):3
>
> The compiler should know that FalseClass is a constant and
> therefore isn't a method call, so the "?" is the operator
> and should be a seperate token.

I'm not sure why, but one can do this:

  irb(main):023:0> def WeirdName? ; puts "hi" ; end
  nil
  irb(main):024:0> WeirdName?
  hi

i.e., Konstant? can be a method name.


David

-- 
David Alan Black
home: dblack / candle.superlink.net
work: blackdav / shu.edu
Web:  http://pirate.shu.edu/~blackdav