Top > Ruby [2.2.2] > inspect


Array# inspect

p ["1","2","3"].to_s          # "[\"1\", \"2\", \"3\"]"
p ["1","2","3"].inspect       # "[\"1\", \"2\", \"3\"]"

puts ["1","2","3"].to_s       # ["1", "2", "3"]
puts ["1","2","3"].inspect    # ["1", "2", "3"]

Ruby 1.8.6までは[ to_s ]と動作に差分があったのですが、
1.9.1から↑のようにまったく一緒です。
何の意味があると思いますが、私には聡明な方の頭はよくわからないですね。
リファレンスとかちゃんと読めばいいのかも知れませんが...



Copyright © 2015 AchaPorutePiipo All Rights Reserved.