Skip to content

Instantly share code, notes, and snippets.

@SteGriff
Created January 28, 2026 14:37
Show Gist options
  • Select an option

  • Save SteGriff/3c3a5c66e234de1c4529d583eeedc00c to your computer and use it in GitHub Desktop.

Select an option

Save SteGriff/3c3a5c66e234de1c4529d583eeedc00c to your computer and use it in GitHub Desktop.
Kotlin playground
import java.time.LocalDate
fun main(){
// Currying and function types
val sum = {a : Int, b : Int -> a + b}
fun add(a: Int, b: Int) = a + b
val add2 = {a : Int -> sum(a,2)}
println(sum(2,2))
println(add2(3))
println(add(3,3))
// Extension with trailing lambda
fun String.sentenceCase() : String = this.lowercase().replaceFirstChar { it.uppercase() }
val dayOfWeek = LocalDate.now().dayOfWeek.toString()
val slogan = "BUGS ROCK"
println("${slogan.sentenceCase()} on a ${dayOfWeek.sentenceCase()}")
// Higher order function
fun caser(arg: String, op: (String) -> String) = op(arg)
val result = caser(slogan, String::sentenceCase)
println(result)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment