Ranter
Join devRant
Do all the things like
++ or -- rants, post your own rants, comment on others' rants and build your customized dev avatar
Sign Up
Pipeless API
From the creators of devRant, Pipeless lets you power real-time personalized recommendations and activity feeds using a simple API
Learn More
Comments
-
eeee31225yThe linter warning marked on the return statement says that this is nonsensical because it cannot be reached: the null!! expression throws before the return is reached.
Expert question: do you know the inferred return type of this return statement? Even something that doesn't return a value has a return type in Kotlin! -
eeee31225y@Trithon it's Nothing.
That makes sense because Nothing is a subtype of all types, but cannot be instantiated. So a function that is declared to return a String, but throws, is valid because it then 'returns' Nothing and execution stops there, because the thrown Throwable must be handled by some catcher.
Throwing is basically a forking point in a thread's execution.
This is also valid Kotlin. Note that this is not a Nothing instance, because the type is Nothing or null, and the value is null. Nothing can't be instantiated (unless there's a bug in the Kotlin compiler).
@highlight
val whatAmI: Nothing? = null -
seriously fuck Kotlin, I had to refactor twice in a month due to Kotlin updates, I hate it so much, nothing makes sense in Kotlin... can't wait for the day we finally delete the last fucking .kt file from the project at work. (we are gradually rewriting everything in Java)
Kotlin
joke/meme