-
Notifications
You must be signed in to change notification settings - Fork 48
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
Trang Frego - SolarSystem #33
base: master
Are you sure you want to change the base?
Conversation
Solar SystemWhat We're Looking For
|
return planet_details | ||
end | ||
|
||
def main |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can probably break up this method a bit more
@color = color | ||
if mass_kg <= 0 | ||
raise ArgumentError, 'Mass must be greater than 0' | ||
else |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You don't need the else, the raise
will exit the method anyway
planet_name.downcase! | ||
planet_name.capitalize! | ||
|
||
planet = @planets.select { |planet| planet.name == planet_name } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You could also use .find
which returns the first one that matches and nil
if nothing matches.
end | ||
|
||
def distance_between(planet1, planet2) | ||
two_planets = @planets.select { |planet| planet.name == planet1 || planet.name == planet2 } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice! 🥇
Solar System
Congratulations! You're submitting your assignment.
Comprehension Questions
initialize
method run? What does it do?Hash
instead of an instance of a class?SolarSystem
class used aHash
instead of anArray
to store the list of planets?require
statements? Which files neededrequire
s, and which did not? What is the pattern?