Mode:
Duration:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
object FunctionCounter {
var count = 0
var isDark = false
val updateUI = () => println(s"Counter: $count, Theme: ${if(isDark) "Dark" else "Light"}")
val increment = () => { count += 1; updateUI() }
val decrement = () => { count -= 1; updateUI() }
val reset = () => { count = 0; updateUI() }
val toggleTheme = () => { isDark = !isDark; updateUI() }
def main(args: Array[String]): Unit = {
updateUI()
increment()
toggleTheme()
decrement()
reset()
}
}
FunctionCounter.main(Array())Coding works best on desktop or with an external keyboard.