Inspect

Hi
What is the use of "inspect"?
for example in this code:

array = [1,2,3,4,5]
# => [1, 2, 3, 4, 5]
array2 = [1, "2", 3.0, ["a", "b"], "dog"]
# => [1, "2", 3.0, ["a", "b"], "dog"]
array.inspect
# => "[1, 2, 3, 4, 5]"
array
# => [1, 2, 3, 4, 5]
puts array
# 1
# 2
# 3
# 4
# 5
# => nil
puts array.inspect
# [1, 2, 3, 4, 5]
# => nil
puts array2.inspect
# [1, "2", 3.0, ["a", "b"], "dog"]
# => nil

···

--
Posted via http://www.ruby-forum.com/.

~> ri Object.inspect
--------------------------------------------------------- Object#inspect
     obj.inspect => string

···

2010/7/22 Amir Ebrahimifard <amiref@ymail.com>:

Hi
What is the use of "inspect"?

------------------------------------------------------------------------
     Returns a string containing a human-readable representation of
     _obj_. If not overridden, uses the +to_s+ method to generate the
     string.

        [ 1, 2, 3..4, 'five' ].inspect #=> "[1, 2, 3..4, \"five\"]"
        Time.new.inspect #=> "Wed Apr 09 08:54:39 CDT 2003"

Cheers,

--
JJ Fleck
PCSI1 Lycée Kléber