by sciurus · 14y ago · 0 comments
def foo s
s = 'foo'
end
a = 'bar'
foo a
puts a
# => bar
The assignment in the method doesn't change the object you "passed" in. Rather than passing by reference, think of Ruby as passing the value of a reference.For more examples and explanation, see http://khelll.com/blog/ruby/ruby-pass-by-value-or-by-referen...
No comments yet.