Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Encapsulation example for my object-oriented programming series in medium.com
class Dragon
def initialize
# ...
end
def fly
take_off
100.times do
move_wings(:horizontally)
end
land
end
private
def take_off
10.times do
move_wings(:vertically)
end
end
def move_wings(direction)
# ...
end
def land
# ...
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.