This is experimental script for zigzag which uses type, method and array. Not recommend for actual usage, for pine script study maybe useful.
In this experiment, I use type as coded below. It seems have limitation as specially when push as array. As Trading View recommendation, pushing float and int into array especially for type not guarantee to work. I agree...
Predicting the future has nothing to do with trading, understanding your indicator and knowing how to use it does.
Probably not the most efficient code, oh well..
Let me know if it's useful :)