Nov 26, 2022
My pleasure!
The reason we reassign is to prevent reentrancy attacks. See Solidity's docs: https://docs.soliditylang.org/en/v0.8.17/security-considerations.html?highlight=checks-effects#re-entrancy
And yes, I don't think there's anything wrong with calling withdrawYield() inside of unstake().