-
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
Space - Faezeh #33
base: master
Are you sure you want to change the base?
Space - Faezeh #33
Conversation
Ride ShareMajor Learning Goals/Code Review
Functional Requirements
Overall Feedback
Code Style Bonus AwardsWas the code particularly impressive in code style for any of these reasons (or more...?)
|
|
||
# based on layering (nesting) method 3: | ||
all_rides = { | ||
:DR0001 => [ |
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.
Don't forget, when you use symbols as a hash key, you can write lines like this as DR0001: [
rides_num = {} | ||
all_rides.each do |driver, rides| | ||
rides_num[driver] = rides.length | ||
end | ||
|
||
driver_total_income = {} | ||
all_rides.each do |driver, rides| | ||
driver_income = rides.map do |each_ride| | ||
each_ride [:COST] | ||
end | ||
driver_total_income[driver] = driver_income.sum | ||
end | ||
|
||
driver_average_rating = {} | ||
all_rides.each do |driver, rides| | ||
driver_rating = rides.map do |each_ride| | ||
each_ride[:RATING].to_f | ||
end | ||
driver_average_rating[driver] = ( driver_rating.sum / rides.length ).round(2) | ||
end |
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 iterate over all_rides
a lot, with a different goal each time. Is there an opportunity to DRY up this code with a single loop of all_rides
and maybe a few methods?
Assignment Submission: Ride Share
Congratulations! You're submitting your assignment. Please reflect on the assignment with these questions.
Reflection
.map
? If so, when? If not, why, or when would be a good opportunity to use it?