Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds method furlong to km #6

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Adds method furlong to km #6

wants to merge 1 commit into from

Conversation

ghost
Copy link

@ghost ghost commented Dec 21, 2013

First Assignment. Used Rspec. Comments welcome.

@@ -4,4 +4,8 @@ class Furlong
def miles_to_kilometers(miles)
miles * KM_PER_MILE
end

def furlong_to_kilometers(furlong)
return furlong * 0.201168
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The 0.201168 looks like a "magic" number here. Instead, I'd like to see a constant "KM_PER_MILE"

Or, if you'd like to not do constants, you can still keep everything defined in the method:

def furlong_to_kilometers(furlong)
  return furlong * furlong_per_mile=0.201168
end

furlong_to_kilometers 1
=> 0.0201

Note I don't love this, but at least future-you can tell what 0.201168 means

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Working example for you: http://rubyfiddle.com/riddles/22ff9

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants