If you want to override `toString()` function in a...
# random
If you want to override
function in an
enum class
you have to use
(at least to my knowledge). I was wondering, are there any other instances where
is mandatory in Kotlin?
Awesome! Thanks. It didn't even cross my mind to look for it online, I thought no one would be insterted to know something like that in StackOverflow. The case of returning functions it's something I didn't know of.
name() is default to_string in enums but under the jvm at least, there are java naming limitations even if you usethe backticks. in 1.7 this is going to get stricter though i would argue for opting into even fewer restrictions personally. even with java enum limitations in kotlin you can get away with a lot of metaprogramming using enums, and of course, minimal fixups following semicolon. https://github.com/0xCopy/1xio/blob/master/src/main/java/one/xio/HttpHeaders.java