Very interesting. Thank you back2dos for demonstrating! Using your sample, I have found something interesting. Check what I did to your sample. I just added a simple call to the actual object and… boom :).
It DOES work if, in the modified sample, you change the signature to:
Well yes, inside the function it is not an array of String but an array of M. container2.push("test") also defeats the purpose of having generic types.
Yeah, you’re right :). I understand now how and why it works. It works only if using the actual types directly in the calls where they are required. Array.push won’t work unless the type is the same generic type.
For example I can’t call this if url is a generic type:
var fileRequest: Http = new Http(url);
Unless I use:
var fileRequest: Http = new Http(cast(url, String));
However, I guess this second case would work if I know that the type converts to String?
@kLabz I edited my response above. I’m curious if it is considered an acceptable use of generic types to create such a function for use for those generic types that can convert to string :).