When to use it
Use it when someone points out an error and they're right. Admitting it quickly ends the debate and shows you care more about getting it right than looking right. Thanking them makes it easier for people to flag issues in the future.
Example
Colleague: “This total doesn't include tax.”
You: “You're right. I had that wrong. Thanks for catching it.”
In an email or Slack message
In a doc comment or thread: “You're right, I had that wrong. Fixed now. Thanks for catching it.” Then make the fix, so the record is clean.