Skip to content

Instantly share code, notes, and snippets.

@systemhalted
Last active September 23, 2020 12:56
Show Gist options
  • Save systemhalted/0b2db9c2303af1fa3ba72667c46dfd12 to your computer and use it in GitHub Desktop.
Save systemhalted/0b2db9c2303af1fa3ba72667c46dfd12 to your computer and use it in GitHub Desktop.
You’re running the REPL with outdated classes: Build module 'HelloKotlin' and restart
Welcome to Kotlin version 1.2.10 (JRE 1.8.0_171-b11)
Type :help for help, :quit for quit
fun whatShouldIDoToday(
mood: String,
weather: String = "sunny",
temperature: Int = 24): String {
return when {
mood == "happy" && weather == "sunny" -> "go for a walk"
else -> "Stay home and read."
}
}
whatShouldIDoToday(mood="happy")
go for a walk
whatShouldIDoToday("sulky")
Stay home and read.
val spices = listOf("curry", "pepper", "cayenne", "ginger", "red curry", "green curry", "red pepper" )
spices.filter { it.contains("curry") }.sortedBy { it.length }
[curry, red curry, green curry]
spices.filter { it[0] == 'c' && it[it.length - 1] == 'e' }
[cayenne]
spices.filter { it.startsWith('c') && it.endsWith('e') }
[cayenne]
spices.take(3).filter { it.startsWith('c') }
[curry, cayenne]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment