Created
July 4, 2022 00:10
-
-
Save JayBazuzi/ca1429ea1d5b7a76de64d7cb7108bc73 to your computer and use it in GitHub Desktop.
Demonstration of asserting events in Kotlin
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
fun main() { | |
val foo = Foo() | |
val aClass = AClass() | |
aClass.OnBaz = foo::Bar | |
aClass.Do() | |
println(aClass.OnBaz == aClass.OnBaz) | |
println(aClass.OnBaz) | |
} | |
class Foo { | |
fun Bar(message: String) { | |
println(message) | |
} | |
} | |
class AClass { | |
var OnBaz: (message: String) -> Unit = { } | |
fun Do() { | |
OnBaz("Hello, World!") | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment