You could absolutely do that and be fucked too. However the point of the pattern I suggested isn’t to replace the return with an assignment. That is, the point isn’t to do the exact same implementation and then do result = something before returning it. Instead it’s to use the initialized result var to directly store your result throughout the function, at every place where you manipulate it. So in this case my suggestion is to not have psize at all. Instead start with intresult=-1; and return result; and do all the things you do to psize except on result. Then there’s a higher chance you will return the right value. Not a guarantee.
But what would that help in this situation? You could as easily write
result = asize;
and thepsize
would again be unused.You could absolutely do that and be fucked too. However the point of the pattern I suggested isn’t to replace the return with an assignment. That is, the point isn’t to do the exact same implementation and then do
result = something
before returning it. Instead it’s to use the initializedresult
var to directly store your result throughout the function, at every place where you manipulate it. So in this case my suggestion is to not havepsize
at all. Instead start withint result = -1;
andreturn result;
and do all the things you do topsize
except onresult
. Then there’s a higher chance you will return the right value. Not a guarantee.