7
7stud 7stud
In irb, an array displays like this:
irb(main):001:0> a = %w(bird dog cat)
=> ["bird", "dog", "cat"]
irb(main):002:0>
Is there a command to get the same format when I display an array with a
program?
r1test.rb:
----------
a1 = %w(cat dog bird)
puts a1
$ ruby r1test.rb
cat
dog
bird
Also, this code:
----------
a1 = %w(cat dog bird)
puts a1
puts
a2 = %w{john joe jim}
puts a2
--output:--
cat
dog
bird
john
joe
jim
-----------------
seems to suggest that braces and parentheses are equivalent. Is that
the case?
Thanks
irb(main):001:0> a = %w(bird dog cat)
=> ["bird", "dog", "cat"]
irb(main):002:0>
Is there a command to get the same format when I display an array with a
program?
r1test.rb:
----------
a1 = %w(cat dog bird)
puts a1
$ ruby r1test.rb
cat
dog
bird
Also, this code:
----------
a1 = %w(cat dog bird)
puts a1
puts
a2 = %w{john joe jim}
puts a2
--output:--
cat
dog
bird
john
joe
jim
-----------------
seems to suggest that braces and parentheses are equivalent. Is that
the case?
Thanks