Actually, trial and error is really the only way you learn photography. It is the best, at least good and the worst way to learn photography. Which one it is depends on the context it is occurring in.
In the formal environment, you are learning, through trial and error, the real dimensions of the course material presented to you in a focused and structured way.
In the self-teaching case, it's the only mechanism of learning and, if you are approaching photography somewhat coherently, it is a good way to learn. If you are one of those who are good in the self-teaching situation - you can structure, or adopt a structure, that will build rationally on the growing foundation - it may be the best method.
If you follow some advice and just take lots of pictures randomly without any framework, it's not even a way to learn.
Vance