Skip to content

Instantly share code, notes, and snippets.

@kalyco
Last active August 29, 2015 14:24
Show Gist options
  • Save kalyco/cb7ad6483fcbc5e27166 to your computer and use it in GitHub Desktop.
Save kalyco/cb7ad6483fcbc5e27166 to your computer and use it in GitHub Desktop.
short example of send() method in rails
class Car
def start
puts "vroom"
end
private
def engine_temp
puts "Just Right"
end
end
@car = Car.new
@car.start # output: vroom
@car.send(:start) # output: vroom
#biggest difference is send lets you posted to private methods:
@car.engine_temp # This doesn't work, it will raise an exception
@car.send(:engine_temp) # output: Just Right
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment