From: Mark Hubbart Date: 2004-07-18T03:23:03+09:00 Subject: Re: Bug? String literal %s{#{a}} cause irb to abort On Jul 17, 2004, at 10:53 AM, Alexey Verkhovsky wrote: > On Sat, 2004-07-17 at 20:34, Mark Hubbart wrote: >> That's because newlines are valid delimiters in that context: > > Aha... now I understand. > To take this hairsplitting exercise a little further, :) > there is a slight > difference between ruby and irb here: > > [alex@dhcp-89-2 alex]$ ruby > %s > > -:2: empty symbol literal > [alex@dhcp-89-2 alex]$ > > [alex@dhcp-89-2 alex]$ irb > irb(main):001:0> %s > irb(main):002:0: > irb(main):003:0> > SyntaxError: compile error > (irb):2: empty symbol literal > from (irb):3 > from :0 > irb(main):004:0> > > So, ruby sees an error after two linefeeds, while irb does it only > after > three. In this test, I used a plus sign to indicate that the statement should continue to the next line: mark@eMac% ruby %s{} + -:1: empty symbol literal %s{} + ^ I think irb waits on the compilation until it gets a full statement; while ruby compiles at the smallest expression level (but still line-based). So, while irb will wait to see if you try to add anything after that empty symbol literal, ruby grabs it right away and shows you where you went wrong. :) > I hope everybody can live with this :) cheers, Mark