fork download
  1. class Car
  2. def initialize
  3. @state = :parked
  4. end
  5.  
  6. def speed
  7. return 0 if @state == :parked
  8.  
  9. 20
  10. end
  11.  
  12. def drive
  13. @state = :driving
  14. end
  15. end
  16.  
  17. car = Car.new
  18. puts car.speed
  19. car.drive
  20. puts car.speed
Success #stdin #stdout 0s 28688KB
stdin
Standard input is empty
stdout
0
20