From: Calamitas Date: 2008-04-24T19:06:57+09:00 Subject: Re: Puzzeling little inconsistency On Thu, Apr 24, 2008 at 11:38 AM, Robert Dober wrote: > I just stumbled upon this, not sure what is going on here. BTW Ruby, > Ruby1.9 and JRuby behave all the like. > > 546/46 > cat syntax.rb && echo "--->" && ruby syntax.rb > module M > def % z > puts z > end > extend self > self % "Top" # Line Fourty Two > end > > extend M > % "Hi" > send "%", "Low" > o = Object.new.extend M > o % "Bottom" > ---> > Top > Low > Bottom > > --------------------------------------------------------------------- > Additionally if you remove self from line Fourty Two, you get a synatx error. > > syntax.rb:9: syntax error, unexpected tCONSTANT, expecting kEND > syntax.rb:13: syntax error, unexpected $end, expecting kEND > --------------------------------------------------------------------- > > I am quite puzzled, any explanations? I'm seeing the same behavior as you are, provided that I remove the comment and add a space after "Hi". The expressions starting with % are interpreted as string literals. Because the following character is a space, it is used as a delimiter. It is an unusual delimiter, but Ruby allows it. Peter