From: Ross Bamford Date: 2006-02-23T02:54:54+09:00 Subject: Re: How does one get a String representation of an Array (not to_s)? On Thu, 2006-02-23 at 02:48 +0900, junk5@microserf.org.uk wrote: > Hi all > > (I know about to_s --- that isn't what this post is about!) > > Say I have an array that I create with: > > a = [1, 2, [3, 4], 5] > > At the irb prompt, Ruby replies: > > => [1, 2, [3, 4], 5] > > So how do I get a String containing "[1, 2, [3, 4], 5]"? Doing a.to_s > gives me "12345", which is not what I want. s = [1,2,[3,4],5].inspect # => "[1, 2, [3, 4], 5]" puts s [1, 2, [3, 4], 5] -- Ross Bamford - rosco@roscopeco.REMOVE.co.uk