Monday, April 23, 2012

Learning Ruby, Looking for Possible Refactoring for If Statement

I've got a few ideas but wanted to get a few other options. Here is the ugly:



    def normal_balance
if type.to_s == 'Asset' or type.to_s == 'Expense'
if contra
"Credit"
else
"Debit"
end
else
if contra
"Debit"
else
"Credit"
end
end
end




No comments:

Post a Comment