passionate hackers in Hong Kong. Agile, Ruby On Rails, Scala and Pen Test
if products.nil? products.first.total_amount else 0.0 end
products.first.try(:total_amount) || 0.0
I think the source code is:```if products.first.present? products.first.total_amountelse 0.0end```Or the second statement does not match at allUnless you mean `products.try(:first).try(:total_amount) || 0.0`But the first code is still wrong :O
I think the source code is:
ReplyDelete```
if products.first.present?
products.first.total_amount
else
0.0
end
```
Or the second statement does not match at all
Unless you mean `products.try(:first).try(:total_amount) || 0.0`
But the first code is still wrong :O