Skip to content

Instantly share code, notes, and snippets.

@h0tk3y
Created April 26, 2016 08:40
Show Gist options
  • Select an option

  • Save h0tk3y/73d74d6343ffda442b6cff1e4088f932 to your computer and use it in GitHub Desktop.

Select an option

Save h0tk3y/73d74d6343ffda442b6cff1e4088f932 to your computer and use it in GitHub Desktop.
package net.russianword.android
/**
* Created by igushs on 4/25/16.
*/
class Translator {
private var indentLevel = 0
private fun writeLn(s: String) {
println(" ".repeat(4 * indentLevel) + s)
}
private fun withIndent(action: () -> Unit) {
++indentLevel
action()
--indentLevel
}
fun f() {
writeLn("123")
withIndent {
writeLn("abc")
writeLn("def")
withIndent {
writeLn("xyz")
writeLn("123")
}
writeLn("456")
}
writeLn("789")
}
}
fun main(args: Array<String>) {
Translator().f()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment