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

Coral Ruschak #13

Open
wants to merge 9 commits into
base: main
Choose a base branch
from
Open

Conversation

Coralruschak
Copy link

No description provided.

@names = []
@food_trucks.each do |truck|
@names << truck.name
end
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is returning all food trucks because each returns the original array.

lib/event.rb Outdated

def food_trucks_that_sell(item)
@food_trucks.find_all do |truck|
truck.inventory[:item] == item
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The key :item will not exist in your hash, you should be looking for the key item (the argument that you are sending in to the method.

@inventory = {}
end

def check_stock(item)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This logic will not work in the situations where the inventory hash is not empty, but does not contain the requested item.

The method is also not working because you are looking for the wrong key. You should be looking for the key item

end

def stock(item, amount)
@inventory[item] += amount
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This would only work if an item already exists in the @inventory hash. But, since this method is the way that we get things into that hash.... that will never work. You are trying to do math on nil

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