This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
so...is customerSession.receiptOrder.discount a boolean? My guess is that it's not, but I can't tell from this code snippet.
The two things you might return should be the same...and int and an int, or a string and a string. 'null' (I think) can be anything, so it probably works in place of a float, which is what you get with your 0.0.
In short, I don't think this is right. I thing you want something like
customerSession.receiptOrder.discount is null ? 0.0 : customerSession.receiptOrder.discount
There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors
Joined: Jul 13, 2009
Ahh a ternary operator is what it is called huh... nice.
Thanks for getting me straightened out, I came up with this working expression.