-
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
Time - Angela #44
base: master
Are you sure you want to change the base?
Time - Angela #44
Conversation
Ride ShareMajor Learning Goals/Code Review
Functional Requirements
Overall Feedback
Your code was generally quite clean and concise however you didn't wind up organizing things into methods which would have made the code a little bit clearer. This was a pretty small program but in the future trying to do things without methods will be challenging. Code Style Bonus AwardsWas the code particularly impressive in code style for any of these reasons (or more...?)
|
drivers = { | ||
DR0001: [ | ||
{ | ||
"3rd Feb 2016": [ |
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.
One note about a confusing point of Ruby. Even if you use quotes if you use the "key": value
syntax instead of the "key" => value
the key will wind up a symbol.
Note the :
before the quotes in the output.
irb(main):001:0> {"3rd Feb 2016": []}
=> {:"3rd Feb 2016"=>[]}
(Yes, symbols can have spaces, you just need to use quotes after the :
.)
puts "#{driver} stats:" | ||
|
||
# The number of rides each driver has given | ||
ride_count = workdays.sum { |dates, rides| dates.sum { | date, rides | rides.count } } |
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 use of a block with .sum
! This lets you skip using a .map
.
This is equivalent to doing:
ride_count = workdays.map { |dates, rides| dates.sum { | date, rides | rides.count } }.sum
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?