A
Amir Ebrahimifard
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
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