From: Joel VanderWerf Date: 2002-04-04T06:51:16+09:00 Subject: Re: Ruby, python, perl, ... Yohanes Santoso wrote: > > Chris writes: > > > In article <3CAB5620.F1D693C1@path.berkeley.edu>, > > Joel VanderWerf wrote: > > > > > Chris wrote: > > > > > > > Ah, but the real magic of """ is something like: > > > > > > > > >>> foo = """here's a single quote mark""" > > > > >>> foo > > > > "here's a single quote mark" > > > > > > What about > > > > > > irb(main):001:0> foo = %{here's a single quote > > > mark} > > > "here's a single quote mark" > > > > You'd still have to escape out any } that might actually occur in the > > string. Only if the { } are not balanced. > foo = %q# quotation marker can be any non-alphanumeric char # > foo2 = %Q@ foo=#{foo} @ I always forget about this. What's really cool is that you can use newlines: irb(main):013:0> foo = % irb(main):014:0" grabs the whole line irb(main):015:0> "grabs the whole line" and for single quoting you can use %q instead of %, and you can use %x for shell escape: ls = %x ls puts ls # ==> string with ls output