re: Daily Challenge #56 - Coffee Shop VIEW POST

FULL DISCUSSION
 

Here you have a version using only ruby hashes:

def bob(type: 'water', money: '0.0')
  exact = {
     'americano' => '2.20',
     'latte'=> '2.30',
     'flat white'=>'2.40',
     'filter'=> '3.50'
  }[type.to_s.downcase] == money

  {
    true => "Here is your #{type.to_s}, have a nice day!",
    false =>  'Sorry, exact change only, try again tomorrow!'
  }[exact]
end

Outputs:

puts bob()
# Sorry, exact change only, try again tomorrow!

puts bob(type: 'Latte', money: '2.50')
# Sorry, exact change only, try again tomorrow!

puts bob(type: 'Latte', money: '2.30')
# Here is your Latte, have a nice day!
code of conduct - report abuse