Conversation
Ride ShareWhat We're Looking For
Hi Cloudy! Your code looks GREAT! It is clean, readable, and logical. I understand exactly where you came from and where you are going in your code. It answers the questions accurately and it's presented in a really wonderful way. Overall, your code is exactly what I'm looking for... And I'm so excited, because if it gets pushed one more level deeper, it will get to where I want it to be. And by that, I mean the one following specific thing: I'd like to see finding the drivers information in a loop. Your code has the following things: driver1_rides = drivers_db[:DR001]
driver2_rides = drivers_db[:DR002]
driver3_rides = drivers_db[:DR003]
driver4_rides = drivers_db[:DR004]
allrides = [driver1_rides, driver2_rides, driver3_rides, driver4_rides]You found EXACTLY what you needed to find: the rides for each driver, and then you put them into an array of allrides.each_with_index do |rides, i|
puts "Driver ##{i+1} #{rides.length} rides"
endIf you can change your code so that That being said, like I mentioned before, your code is not a mess: it's logical, it's clear, and it's efficient. Well done on those accounts-- your syntax is all right, your code is all good-looking, it's just missing that one step of going from hard-coded driver data to full-on iteration for each step. |
| # puts "#{driver2_rides.length} rides" | ||
| # puts "#{driver3_rides.length} rides" | ||
| # puts "#{driver4_rides.length} rides" | ||
| allrides = [driver1_rides, driver2_rides, driver3_rides, driver4_rides] |
There was a problem hiding this comment.
Very small nitpick but: to follow Ruby naming conventions more closely, allrides should be all_rides
ride share
Congratulations! You're submitting your assignment.
Comprehension Questions
.map? If so, when? If not, why, or when would be a good opportunity to use it?