7/7 Overdraft error...how?


#1

Hi, I'm on to the extra part of the exercise and trying to figure out how to display an error if the amount being withdrawn is more than the amount available.
I've tried a couple of ways, including an if/elsif/else statement (see below), but that didn't work.

Any help would be great!

def withdraw(pin_number, amount)
        if pin_number = pin && @balance -= amount < 0
            puts "You are in overdraft. Balance: $#{@balance}"
        elsif pin_number = pin 
            @balance-= amount
            puts "Withdrew #{amount}. New balance: $#{@balance}."      
        else
            puts pin_error
        end        
    end


#2

@satty10,
Try it with

if pin_number == pin && @balance < amount
#
#
elsif pin_number == pin