R
Rob Biedenharn
irb(main):003:0> print [1, 2, 3]
[1, 2, 3]=> nil
Are you sure about that? I get this:
irb(main):001:0> print [1, 2, 3]
123=> nil
The result you showed should probably be produced by:
print [1, 2, 3].inspect
It all depends on what ruby you're using:
$ rvm ruby -e 'a=[1,2,3];puts "to_s",a.to_s; puts "inspect",a.inspect'
info: jruby-1.5.1: jruby 1.5.1 (ruby 1.8.7 patchlevel 249) (2010-06-06
f3a3480) (Java HotSpot(TM) Client VM 1.5.0_24) [i386-java]
Unable to find a $JAVA_HOME at "/usr", continuing with system-provided
Java...
to_s
123
inspect
[1, 2, 3]
info: ree-1.8.7-head: ruby 1.8.7 (2009-06-12 patchlevel 174) [i686-
darwin9.8.0]
to_s
123
inspect
[1, 2, 3]
info: ruby-1.8.6-p383: ruby 1.8.6 (2009-08-04 patchlevel 383) [i686-
darwin9.8.0]
to_s
123
inspect
[1, 2, 3]
info: ruby-1.9.1-p378: ruby 1.9.1p378 (2010-01-10 revision 26273)
[i386-darwin9.8.0]
to_s
[1, 2, 3]
inspect
[1, 2, 3]
info: ruby-1.9.2-p0: ruby 1.9.2p0 (2010-08-18 revision 29036) [i386-
darwin9.8.0]
to_s
[1, 2, 3]
inspect
[1, 2, 3]
So you might both be "right" on this.
-Rob
Rob Biedenharn
(e-mail address removed) http://AgileConsultingLLC.com/
(e-mail address removed) http://GaslightSoftware.com/