And in this sense, gambling can probably even be compared to some extent with a very strict and unforgiving teacher.
And by the way, many of us probably remember our teachers who were really strict, but also fair. I even think that any person, becoming an adult, often remembers just such teachers who really taught him something useful in life and taught him well becaase of rigor and fairness.
I think that gambling can be considered a strict and fair teacher in a broad philosophical sense.
To a great extend, I agree with you, we can as well also compare or liken gambling to life itself, and this because life is a brutal and unforgiving teacher, life is ready to teach a man as many times as he or she needs to learn, and she doesn't care how much you have lost, or how difficult the lesson is, she will continue to you brutally without mercy until you learn.
Same also is gambling, for a gambler who fail to properly learn how to participate in gambling without getting involved in problems, such a gambler will keep encountering problems in gambling until he or she learns to gamble responsibly.