It's a good thing Ruby makes this so easy to fix:
class Array
def to_s
self.inspect
end
end
Issac
-----Original Message-----
From: Issac Trotts [mailto:ITrotts / IdolMinds.com]
Sent: Wednesday, December 12, 2001 11:22 PM
To: ruby-talk / ruby-lang.org
Subject: [ruby-talk:28388] The maddening output of Arrays
Can anyone tell me why Ruby outputs arrays without
any indication that what it's printing is an array?
For instance, why does
print "my obj is #{[1]}"
produce
my obj is 1
rather than
my obj is [1]
?
It seems silly to have to type out inspect
each time, and it's error-prone besides.
print "print "my obj is #{[1].inspect}"
May I be so bold as to propose changing this
surprising behavior while Ruby is still young
and not tied to a mammoth legacy code base?
Issac