1. Used alone in response to a question as to whether you have done or experienced something, or met someone, to mean that you have and that it was not a pleasant or memorable experience. You are glad that it is in the past and behind you.
2. Used alone to mean that something unexpected or bad happened because of what you did and that you have learnt from this experience. Idiomatic English = "that'll teach me", "I've learnt my lesson!"