Last active
August 29, 2015 14:00
-
-
Save Ross-Hunter/11144996 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## Contrived Example | |
# Will the thing float? | |
class Thing | |
attr_accessor :mass, :volume | |
def will_i_float? | |
(mass / volume) < 1 | |
end | |
end | |
# vs | |
class Thing | |
attr_accessor :mass, :volume | |
def will_i_float? | |
density < density_of_water | |
end | |
def density | |
mass / volume | |
end | |
def density_of_water | |
1 # g/mL | |
end | |
end | |
## End Contrived Example |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment