Hacker News new | ask | show | jobs
by ezekg 1831 days ago
I've used the tilde operator in Unity + C# quite a bit when mutating bitmasks that store state. For example, my player movement code manages its state within a bitmask. To remove a certain state, I do something like this to ensure the player exits a given state:

    if ((state.CurrentState & EPlayerState.Sliding) != 0)
    {
      state.NextState &= ~EPlayerState.Sliding;
    }
Outside of hobby game dev, I've never used it. From the PR, I'm not sure Go devs want it.