From: Robert Klemme Date: 2004-02-12T20:59:58+09:00 Subject: Re: (noob) cast string to array? "Simon Strandgaard" schrieb im Newsbeitrag news:pan.2004.02.12.00.39.08.258666@adslhome.dk... > On Thu, 12 Feb 2004 00:31:29 +0000, Koncept wrote: > > Hi. What a fantastic language. This is my first day learning using it > > and I *love* it so far. > > Great.. Welcome to Ruby. > > [snip] > > > > result = result.sub(/\{/,'[') > > result = result.sub(/\}/,']') > > What you has written is the same as (notice the '!' suffix) > > result.sub!(/\{/,'[') > result.sub!(/\}/,']') > > Above can be chained, so it becomes > > result.sub!(/\{/,'[').sub!(/\}/,']') I always feel unconfortable chaining (g)sub! since the result here *may* be nil. I'd rather do array = eval( result.gsub( /\{([^}]*)\}/, '[\\1]' ) ) robert