what is return a=true?

May 1, 2017 at 6:19am
I understand
 
  return a==true;

But what is a return statement as below?
 
  return a=true;

Does it mean first to assign true to a, then return true?

Thanks,

L
May 1, 2017 at 6:43am
Equivalent to return ( a = true ) ;
Assign true to a; return the result of the assignment (the result of the assignment is typically a reference to a).
May 1, 2017 at 9:03am
JLBorges wrote:
return the result of the assignment (the result of the assignment is typically a reference to a

"Typically", meaning all integral types, most if not all of the standard library, and most classes.
May 1, 2017 at 11:46am
I suddenly got this. This is like what happen to" return a++;" and "return ++a".

Thanks,
L
May 2, 2017 at 7:24am
a++ would return a not incremented and ++a would return a incremented.
May 2, 2017 at 9:35pm
> I understand
> return a==true;
I don't. Surely you may do return a;
May 4, 2017 at 12:15am
ne555 wrote:
I don't. Surely you may do return a;

I think the OP means he/she understands what it does.
Last edited on May 4, 2017 at 12:15am
Topic archived. No new replies allowed.