Created
June 27, 2012 18:09
-
-
Save kapso/3005776 to your computer and use it in GitHub Desktop.
Ruby parameter passing by value or reference? (its by REF)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Car | |
def start(options) | |
options[:speed] = 60 | |
puts "running @ #{options[:speed]}" | |
end | |
end | |
op = { speed: 50 } | |
puts op.inspect | |
Car.new.start op | |
puts op.inspect | |
# prints out the following | |
# {:speed=>50} | |
# running @ 60 | |
# {:speed=>60} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment