App Academy

Don't understand why?

Hi !

why the first function results are different from the second!


def f1

x = 1

puts x.object_id

return x

end

puts f1.object_id

y = f1

puts y.object_id

#The result is :

3

3

3

3

#-------------------


def f2

a = [1]

puts a.object_id

return a

end

puts f2.object_id

b = f2

puts b.object_id

#The result is :

60

60

80

80

#-------------------