# Inspect

**URL:** <https://www.ruby-forum.com/t/inspect/192016>\
**Category:** Ruby\
**Created:** [July 22, 2010, 1:39pm UTC](https://www.ruby-forum.com/t/inspect/192016 "2010-07-22T13:39:55Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![amiref](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/41988e/32.png) [@amiref](https://www.ruby-forum.com/u/amiref)\
**Post date:** [July 22, 2010, 1:39pm UTC](https://www.ruby-forum.com/t/inspect/192016/1 "2010-07-22T13:39:55Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![amiref](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/41988e/32.png) [@amiref](https://www.ruby-forum.com/u/amiref)\
**Post date:** [July 22, 2010, 2:44pm UTC](https://www.ruby-forum.com/t/inspect/192016/2 "2010-07-22T14:44:02Z")

</div>

2010/7/22 Amir E. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid):

> 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,
