Skip to content

Instantly share code, notes, and snippets.

a = 'hello'
b = a
a = 'goodbye'
a = 'hello'
b = a
a = 'goodbye'
a = 4
loop do
a = 5
b = 3
break
end
puts a
puts b
a = 4
b = 2
loop do
c = 3
a = c
break
end
puts a
a = 4
b = 2
2.times do |a|
a = 5
puts a
end
puts a
puts b
a = 4
b = nil
loop do
a = 5
b = 3
break
end
puts a
a = 4
b = 2
2.times do |_|
a = 5
puts a
end
puts a
puts b
a = 'hello'
puts a # -> hello
puts a.object_id # -> 70368527757720 (this number will be different for you)
a.upcase!
puts a # -> HELLO
puts a.object_id # -> 70368527757720 (this number will be the same as the one above)
a = 'hello'
puts a # -> hello
puts a.object_id # -> 70368468160540 (this number will be different for you)
a.upcase
puts a # -> hello
puts a.object_id # -> 70368468160540 (this number will be the same as the one above)
a = 'name'
b = 'name'
c = 'name'
# Are these three local variables pointing to the same object?
puts a.object_id
puts b.object_id