Hi, TypeScript uses the same convention to descri...
# announcements
p
Hi, TypeScript uses the same convention to describe constraints for generic types for both classes and functions e.g.
function foo<T extends Bar>() {}
and
class Foo<T extends Bar> {}
. Just out of curiosity were there any limitations why it couldn't be like
fun foo<T : Bar>() {}
in Kotlin?
🤔 1
Yes
Classes are described like
class Foo<T : Bar>
so I'm wondering why functions do not follow the same convention.
Yes the main reason I'm asking is why they do not follow the same convention as classes or vice versa.
I wanted to make it more clear as you pointed out a lot of mistakes in the question. Sorry 😄
d
I was wondering this some time back, forgot what the answer was..
k
I remember reading a Kotlin discussions thread about this a while ago, and I think the explanation was the receiver type:
fun T.foo<T>()
is weird. The same reason works for Java with the return type:
public T foo<T>()
would be weird.
âž• 1
"weird" as in "a type is used before it is declared"
p
I think the explanation was the receiver type:
fun T.foo<T>()
is weird.
probably this is why they chose the current syntax.