12
Considering that in the Ruby programming language everything is said to be an Object, I safely assumed that passing arguments to methods are done by reference. However this little example below puzzles me:
$string = "String"
def changer(s)
s = 1
end
changer($string)
puts $string.class
String
=> nil
As you can see the original Object wasn't modified, I wish to know why, and also, how could I accomplish the desired behavior ie. Getting the method to actually change the object referenced by its argument.