You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When overloading a generic function that takes an argument of any type,
it is trivial to specialize it for a specific case by simply using that type for an argument:
def polymorph(a: type T) -> T {
return a
}
def polymorph(a: int) -> int {
return 20
}
However, for type parameters this is currently impossible.
It could look like this:
def polymporph(type T) -> int {
return size_of T
}
def polymporph(int) -> int {
return 20
}
Note that this doesn't conflict with default parameters, those would use an =
The text was updated successfully, but these errors were encountered:
When overloading a generic function that takes an argument of any type,
it is trivial to specialize it for a specific case by simply using that type for an argument:
However, for
type
parameters this is currently impossible.It could look like this:
Note that this doesn't conflict with default parameters, those would use an
=
The text was updated successfully, but these errors were encountered: