So I noticed that Kotlin tends to have several ways of doing the same thing1. Sometimes these are actually identical, sometimes there are subtle differences.
That makes things hard for me.
Let's take this trivial example.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
There is no difference. The one thing you could mention is that emptyList() more accurately conveys what you are trying to do.
There's something similar in Java. Collections.emptyList() versus List.of(). The comments on [2] seems to be very interesting.
In Java one could argue that List.of() is new, so should be used. And we could assume that the Language Architects in Java wouldn't add a List.of() for no reason.
I just thought I'd write some things down that I already know, but sometimes it's nice to see this proven.
It's a very very beginner Java subject, but people won't fault me for blogging about it.
It might be of some use to somebody.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters