I reading the Agile Development Ruby book and came accross a line of
code that I dont quite understand…
errors.add(:price, “should be positive”) unless price.nil? || price >
The line of code works but I dont quite understand the logic behind it.
It prints the error message “price should be positive” when the price
entered is either 0 or less than 0.
This is where i dont understand the logic - the price.nil operator
returns a true if price is zero and the price > 0 returns a true if the
price is more than zero (logically this would have to be price < 0)?
If someone could explain the logic here then that would be great.
Thanks in advance!