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

2010/7/22 Amir E. [email protected]:

Hi
What is the use of “inspect”?

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

 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,