Yes, you can assign the value of variable inside if.
I wouldn't recommend it. The problem is, it looks like a common error where you try to compare values, but use a single =
instead of ==
or ===
.
It will be better if you do something like this:
int v;
if((v = someMethod()) != 0)
return true;