From: Robert Dober Date: 2006-09-20T20:43:28+09:00 Subject: Re: Something strange in ruby or I'm a newbie? ------=_Part_169986_24959286.1158752605974 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: quoted-printable Content-Disposition: inline On 9/20/06, Morton Goldberg 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 =3D 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. > > Regards, Morton No he found something really strange look at this puts "a" +"b" Do you get his point? Robert --=20 Deux choses sont infinies : l'univers et la b=EAtise humaine ; en ce qui concerne l'univers, je n'en ai pas acquis la certitude absolue. - Albert Einstein ------=_Part_169986_24959286.1158752605974--