Carets - Julia Meier - Rideshare#32
Open
julmeier wants to merge 1 commit into
Open
Conversation
tildeee
reviewed
Aug 16, 2017
| # 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.
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! :) :) :)
tildeee
reviewed
Aug 16, 2017
| 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.
Were you creating the hash with hash rocket notation ( => ) or symbol notation?
tildeee
reviewed
Aug 16, 2017
| 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.
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. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.