inline-option/README.md
2020-10-02 16:29:09 +02:00

18 lines
702 B
Markdown

# inline-option
An implementation of an `Option<A>` type in Kotlin using the `inline class` feature.
See https://kotlinlang.org/docs/reference/inline-classes.html
It’s just a small proof of concept
sparked by the discussion on the arrow-kt issue tracker after they decided to deprecate `Option`
because nullable types are more efficient.
It’s just a single file, so I decided to omit the usual gradle bloat,
Build and test via:
```sh
$ kotlinc-native Option.kt OptionTest.kt
$ ./program.kexe
```
The implementation uses an empty value placeholder to allow for nullable types (i.e. `Option<Int?>`).
I don’t think those are ever a good idea to have, but I saw no reason not to support them.