Skip to content

Instantly share code, notes, and snippets.

@soudmaijer
Created May 2, 2021 19:16
Show Gist options
  • Save soudmaijer/e6295dd7537040eb8726fb81dbb5d61f to your computer and use it in GitHub Desktop.
Save soudmaijer/e6295dd7537040eb8726fb81dbb5d61f to your computer and use it in GitHub Desktop.
fun using_with() {
val stringBuilder = StringBuilder()
stringBuilder.append("Hello")
stringBuilder.append(", Kotlin!")
print(stringBuilder.toString())
}
fun using_also(a: Int): Int {
val b = a * 10
if (b > 100) print(">100")
return b
}
fun using_apply(): java.util.Properties {
val properties = java.util.Properties()
properties.setProperty("key", "value")
return properties
}
fun using_let(p: java.util.Properties?, key: String) {
if (p != null) print(p.getProperty(key))
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment