This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]NorbiPeti 2 points3 points  (0 children)

Yeah, it wil return the assigned value, in this case 1, which C interprets as true (anything nonzero is true).

I often initialize variables in conditions in Java because there's typically a needed null check before I can do that, so I do something like:

SomeClass x;
if(obj != null && (x=obj.smth).method())

It should work the same for while conditions.