Skip to content
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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

julmeier
Copy link

No description provided.

# 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?
Copy link

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:
Copy link

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]
Copy link

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 :)

@tildeee
Copy link

tildeee commented Aug 16, 2017

You show mastery over accessing values in nested arrays and hashes! I've added some comments to this pull request for your questions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants