I was going through the code in corona cannon and stumbled upon this. I tried to figure out the purpose of its usage.
function cannon:getAmmoCount() return #balls + (self.ball and 1 or 0) end
I ended up with the following error :- attempt to perform arithmetic on a table value. when i removed the or operator.
function cannon:getAmmoCount() return #balls + (self.ball and 1) end
Can someone explain how self.ball a table value doesn't show error using the first approach, but does when i change it to the second approach. I have a vague idea what it could be, but i'm not sure.