Can someone please explain, in simple English, the logic behind this statement?
return mContainsLoadingRow ? (getContentDataSize() + 1) : getContentDataSize();
Assuming mContainsLoadingRow is a boolean, if mContainsLoadingRow is true,
then return getContentDataSize() + 1.
If not, return getContentDataSize().
Is that the correct way to look at this?
this complete expression is know as Ternary Operator in Java.
mContainsLoadingRow ? (getContentDataSize() + 1) : getContentDataSize();
|| || ||
//boolean expression //return if true //return if false
here in this code
mContainsLoadingRow is a Boolean variable which contains either true or false. you can also change mContainsLoadingRow with any Boolean expression like (a>b or b==a or b <= a etc.)
? (question mark) :- enables us to fine whether it is true or false.
if true the expression (getContentDataSize() + 1) will be return.
if false then expressin getContentDataSize() value will be return.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With