(noob) cast string to array?


(Michael Campbell) #1

Simon Strandgaard wrote:

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!(/}/,’]’)

Any suggestions are more than welcome.

Try ‘gsub’

result.gsub!(/{/,’[’).gsub!(/}/,’]’)

Very dangerous. If one of the ! methods doesn’t actually do
anything, it returns nil, which responds poorly to subsequent !
methods.

···

Do you Yahoo!?
Yahoo! Finance: Get your refund fast by filing online.