language design question: ```interface MyInterface...
# announcements
l
language design question:
Copy code
interface MyInterface<T> {} //interface declaration
class MyClass<T> : MyInterface<String> {} //class declaration and interface implementation
val x = MyClass<String>() //class construction
fun <T> foo() {} //function declaration
val y = foo<String>() //function call
type parameters are always specified after the name, except in the case of function declarations. why this inconsistency? why isnt the syntax for it like this
Copy code
fun foo<T>() {}
to be consistent ?
👍 1
i
The idea behing this syntax is that a type parameter should be declared before it is used in a declaration. In functions it can be used even before the function name in case of extension functions with generic receiver, e.g:
fun <T> T.foo(): T
👍 3