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
···
On Thu, Apr 24, 2008 at 11:38 AM, Robert Dober <robert.dober@gmail.com> 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.
Oh thanx Peter, I just had the idea to use parse tree the next time
before asking stupid questions ;).
Side remark to Guy, I know what you meant with your examples now, but
I believe that your examples were consistent with % being a method I
did therefore not understand.
R.
···
On Thu, Apr 24, 2008 at 12:06 PM, Calamitas <calamitates@gmail.com> wrote:
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