On 9/20/06, Morton Goldberg <m_goldberg / ameritech.net> wrote:
> On Sep 20, 2006, at 6:32 AM, Hussachai Puripunpinyo wrote:
>
> > Question 1:
> >
> > #IS THIS A BUG
> > class TestBug
> >   def test
> >     "Hello Bug"
> >   end
> > end
> > class FoundBug < TestBug
> >   def test
> >     super +" ,I found you !" #Notice here
> >   end
> > end
> > test = FoundBug.new()
> > puts test.test
> >
> > It blame me that
> >  "undefined method `+@' for " ,I found you !":String (NoMethodError)
> >       from C:/DOCUME~1/HUSSAC~1/LOCALS~1/Temp/rb1F.tmp:12"
> > Why?
> > This is bug or I miss something?
> >
> > If I replace the line in '#Notice here' to
> >
> > super+" ,I found you !" #With no space between super and my string
> > #OR
> > super + " ,I found you !" #With space both side of '+'
> > #I found that no error
> >
> > Why?
>
> No, I'm afraid it's a feature ;).  if you rewrite
>
> >     super +" ,I found you !" #Notice here
>
> to
> >     super + " ,I found you !" #Notice space after '+'.
>
> it will work. By leaving out the space, you have invoked the unary
> '+' operator. But, of course, you wanted the binary '+' operator. In
> Ruby there are times when spaces and parentheses are critical.

In other words,

super +"whatever" is the same as super(+"whatever") while
super+"whatever" or super + "whatever" is the same as super(*args) + "whatever".

right?