Skip to content

Instantly share code, notes, and snippets.

@Naomi-Dennis
Last active January 16, 2020 20:53
Show Gist options
  • Save Naomi-Dennis/8b5ff8650e4dbc91437950fe4e845fed to your computer and use it in GitHub Desktop.
Save Naomi-Dennis/8b5ff8650e4dbc91437950fe4e845fed to your computer and use it in GitHub Desktop.
def items
[ShopItem.new(20, "Paper"),
ShopItem.new(50, "Ball"),
ShopItem.new(40, "Book"),
ShopItem.new(4, "Chips")]
end
def find_item(item_name)
items.select do | item |
item.name == item_name
end.first
end
item = "Ball"
searched_item = find_item(item)
unless searched_item.nil?
money = perform_transaction(money, searched_item)
else
puts "We don't sell that item"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment