Skip to content

Instantly share code, notes, and snippets.

@JosephLeon
Last active April 10, 2016 00:23
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 JosephLeon/73117140f098eef7e80a0cac2fde94b8 to your computer and use it in GitHub Desktop.
Save JosephLeon/73117140f098eef7e80a0cac2fde94b8 to your computer and use it in GitHub Desktop.
class Gear
attr_reader :chainring, :cog
def initialize(chanring, cog)
@chainring = chainring
@cog = cog
end
def ratio
chainring / cog.to_f
end
end
puts Gear.new(52, 11).ratio
## ERROR
init.rb:9:in `ratio': undefined method `/' for nil:NilClass (NoMethodError)
from init.rb:13:in `<main>'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment