Title / Description
Code class Bicycle attr_reader :size, :chain, :tire_size def initialize(**opts) @size = opts[:size] @chain = opts[:chain] || default_chain @tire_size = opts[:tire_size] || default_tire_size end def default_chain "11-speed" end # ... end class RoadBike < Bicycle # ... def default_tire_size "23" end end class MountainBike < Bicycle # ... def default_tire_size "2.1" end end
Author
Highlight as C C++ CSS Clojure Delphi ERb Groovy (beta) HAML HTML JSON Java JavaScript PHP Plain text Python Ruby SQL XML YAML diff code