Skip to content

Instantly share code, notes, and snippets.

@kapso
Created June 27, 2012 18:20
Show Gist options
  • Save kapso/3005829 to your computer and use it in GitHub Desktop.
Save kapso/3005829 to your computer and use it in GitHub Desktop.
Ruby by reference or value? (in this example it created a copy)
class Car
def start(speed)
speed = 60
puts "running @ #{speed}"
end
end
speed = 40
puts speed
Car.new.start speed
puts speed
# prints the following
# 40
# running @ 60
# 40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment