I’m trying to convert some C# code I have and one problem I can’t find a solution for is to have a function take parameters of unknown types.
C# code:
public T Maximum<T>(T v1, T v2)
{
return v1 > v2 != null ? v1 : v2;
}
A straight translation to AS3 would look something like this, for making it easier to understand for people that might be confused by C# syntax.
public function Maximum<T>(v1:T, v2:T):T
{
return v1 > v2 != null ? v1 : v2;
}
This way you can send in anything as the parameters (notice the <T>), be different classes for example, depending on what situation you want to use it, instead of writing a lot of duplicate functions for every possible parameter type.
Is there a way to do this in AS3?
Edit: Seems like I managed to find a solution right after I wrote this. Seems like one can use “*” as parameter type.