:wave: Hi all, new to Kotlin and I'm having troubl...
# getting-started
c
👋 Hi all, new to Kotlin and I'm having trouble understanding why the
->
is used to specify return types in some cases but not others (e.g.
:
is used in
fun
). Is there a reason for this perceived inconsistency?
k
Where is
->
used for return types? It's used in lambdas for the return value.
p
@karelpeeters it is used to indicate the return type of a function type: var f : (Int) -> Int = ... It's the same as in many functional programming languages, but besides that I don't really know the reason. Always seemed more natural to me
k
Ah right, forgot that one. Maybe that's because
f: (Int) : Int
is a lot more difficult to read?