Skip to content

Instantly share code, notes, and snippets.

@JH108
Last active February 3, 2021 15:00
Show Gist options
  • Save JH108/8b29e5674dc974c16ae913953d36ea77 to your computer and use it in GitHub Desktop.
Save JH108/8b29e5674dc974c16ae913953d36ea77 to your computer and use it in GitHub Desktop.
Random Kotlin Code
import kotlinx.coroutines.*
import kotlinx.coroutines.channels.*
import kotlinx.coroutines.selects.*
import java.text.*
import java.util.*
// Define variables
val names = arrayOf("What", "Even", "is", "this🤯")
val longName = "Some random function name"
// Use a variable as a function name
fun `$longName`() {
println("I cannot believe that this is a thing!")
}
fun main() {
names.forEach {
// Use more variables as function names so we can dynamically name functions 🤯
fun `$it`(thing: String) {
println("UnB $thing")
}
`$it`(it)
}
`$longName`()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment