This file contains hidden or 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
class Refined<A : Any>( | |
default: A, | |
private val errorMsgGen: (A) -> String = { | |
"Value: $it does not meet its constraints!" | |
}, | |
private val validator: (A) -> Boolean = { true } | |
) : ReadWriteProperty<Refined<A>?, A> { | |
private var backingField: A = default | |
override operator fun getValue(thisRef: Refined<A>?, property: KProperty<*>): A { |
This file contains hidden or 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
class Foo { | |
// This will not work because its not a static method! | |
// You cannot annotate it with @JvmStatic (usable only | |
// in objects and companion objects) | |
// You have 4 options: | |
fun main(args: Array<String>) { | |
prinltn("This won't work as expected") | |
} | |
// this will clash with main above during compilation! |