Launch Ruby on mac terminal
irb
a=1
def method_primitive(a)
a=2
end
method_primitive a #2
a #1 #Hasn't changed
temp={}
temp[1]=1
def method_reference(temp)
temp[1]=2
end
method_reference temp #2
temp[1] #2 #It has changed
Recommended Posts