Last active
March 17, 2023 13:26
-
-
Save s1monw1/0d891391ab433bd1c291a3da318a4c7e to your computer and use it in GitHub Desktop.
This file contains hidden or 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
class PrintingScope( | |
val separator: String = "________________" | |
) | |
class TimeScope { | |
fun getCurrentTime(): LocalTime = | |
LocalDateTime.now().toLocalTime().truncatedTo(ChronoUnit.SECONDS) | |
} | |
context(PrintingScope, TimeScope) | |
fun <K, V> Map<K, V>.customPrint() { | |
println("Current time when printing: ${getCurrentTime()}") | |
forEach { (k, v) -> | |
println("K: $k") | |
println("V: $v") | |
println(separator) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment