Possible Duplicate:
Shortcut “or-assignment” (|=) operator in Java
I found the following example code in the Android SDK docs:
boolean retValue = false;
retValue |= mActionBarHelper.onCreateOptionsMenu(menu);
retValue |= super.onCreateOptionsMenu(menu);
Can anyone show me equivalent code, to demonstrate what this does?
Note: I assume the method calls return a boolean value, so I like to see an example what this looks like as an if-else construct.
Shorthand for
orwith myself and assign to me, though it is non-short circuitorinstead of logicalor. As it is available as a short version of assigning and or:ing sometimes used anyway with booleans, as there is no ||=.But important note: in this case it will call both methods even though retValue might already be
trueSo equivalent (logic wise) statements can be several, but some would be:
or