M
Mike Novecento
Ok guys, you convinced me: Ruby is the way to go. I have been reading
online for a few hours now, and it looks simply fantastic (especially
with Ruby on Rails).
I am so excited, I have been programming for years, and never thought
it could be so fun.
I have a first question. Looking at some code online, I have seen this
line of code from a the site of pragmatic programmer:
errors.addprice, "should be positive") unless price.nil? || price >
0.0
I understand that it is required to validate that a price is strictly
positive.
My question, maybe very easy, is... how does it exactly work?
I thought it should be "ADD ERROR unless NOT NIL AND PRICE > 0.0"...
why he uses (OR) ||? Maybe I am missing the logic of the keyword
"unless". I feel dumb
Thanks in advance,
Mike.
online for a few hours now, and it looks simply fantastic (especially
with Ruby on Rails).
I am so excited, I have been programming for years, and never thought
it could be so fun.
I have a first question. Looking at some code online, I have seen this
line of code from a the site of pragmatic programmer:
errors.addprice, "should be positive") unless price.nil? || price >
0.0
I understand that it is required to validate that a price is strictly
positive.
My question, maybe very easy, is... how does it exactly work?
I thought it should be "ADD ERROR unless NOT NIL AND PRICE > 0.0"...
why he uses (OR) ||? Maybe I am missing the logic of the keyword
"unless". I feel dumb
Thanks in advance,
Mike.