-
Notifications
You must be signed in to change notification settings - Fork 44
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
Carets - Julia Meier - Rideshare #32
base: master
Are you sure you want to change the base?
Conversation
# QUESTIONS | ||
# 1- Why did I have to put quotes around DR0001. WHen I didn't use quotes it gave me this error: | ||
# Julia_rideshare2.rb:2:in `<main>': uninitialized constant DR0001 (NameError) | ||
# How can I make one hash to store the number_of_trips, earnings and ratings data instead of three separate ones? |
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 absolutely make one hash to store this information ;)
Within your loop, you can calculate and print the appropriate information! Instead of iterating through trips_hash
on line 45, you can print that same line (line 46) in your driver
loop (before it ends on line 43).
There are other alternatives:
- You can make a hash that stores all of those as key/value pairings that you associate with all of the calculated data
- You can make a CLASS! called Driver! and a class called Ride! :) :) :)
end | ||
|
||
# QUESTIONS | ||
# 1- Why did I have to put quotes around DR0001. WHen I didn't use quotes it gave me this error: |
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.
Were you creating the hash with hash rocket notation ( => ) or symbol notation?
sum_of_ratings = 0 | ||
number_of_trips.times do |x| | ||
total_earnings = total_earnings + driver[drivername][x][:cost] | ||
sum_of_ratings = sum_of_ratings + driver[drivername][x][:rating] |
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.
in this specific loop, driver[drivername]
is actually the same as ride_array
:)
You show mastery over accessing values in nested arrays and hashes! I've added some comments to this pull request for your questions. |
No description provided.