News for hackers. Stuff that matters.
Re:From zero to 10M lines of Kotlin by MajimasEyepatch on Tuesday October 25, 2022 @10:30AM (#33330928)
In practice, the return type is often obvious. You can write:

  val foo = new MyReallyLongUglyFactoryClass()
instead of:

  MyReallyLongUglyFactoryClass foo = new MyReallyLongUglyFactoryClass()
And you never _have_ to use type inference. If you have a method where the return type isn't as obvious, you can always annotate it explicitly:

  val foo: Int = doSomeThing()
Do people exercise judgement about when to make the type explicit? Eh, depends on the team. But if you combine type inference with established conventions in a particular codebase (e.g. I/O calls always return IO[Foo]), you will rarely be left wondering what the type of something is.

There are no comments on this comment yet.