Skip to content

Instantly share code, notes, and snippets.

@dekellum
Created September 25, 2009 19:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dekellum/193768 to your computer and use it in GitHub Desktop.
Save dekellum/193768 to your computer and use it in GitHub Desktop.
# Started with something like this
class GoKart
def initialize( strategy = nil )
@strategy = strategy
end
def drive
if @strategy == :reverse
puts "Reverse"
else
puts "Forward"
end
end
def stop
puts "Stop"
end
end
# And have external consumer doing this:
k = GoKart.new()
k.drive
k.stop
k = GoKart.new( :reverse )
k.drive
k.stop
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment