From: nobu.nokada@... Date: 2003-01-16T17:33:18+09:00 Subject: Re: ruby-dev summary 19198-19345 Hi, At Thu, 16 Jan 2003 14:08:58 +0900, Gavin Sinclair wrote: > I think I might start using that more often. It's nice, and it's > easier to chain. e.g. with an appropriate String#tabto(n) method (a > la StringFormattingFunctions on the Wiki), you can resolve the > indentation like so: > > s = %Q{ > hi > how are you? > }.tabto(0) > > Which gives "\nhi\n how are you?\n". That code would highlight fine, > whereas using here-docs can sometimes be troublesome. > > One difference between this and a here-doc is the initial newline, > which is a shame. One more difference. tabto strips after string interpolcation, whereas here-doc does before it. hi = " hi" s0 = %q{ #{hi} how are you? }.tabto(0) # => "\nhi\nhow are you?\n" s1 = <<|EOS |#{hi} | how are you? EOS # => "\n hi\n how are you?\n" -- Nobu Nakada