Created
April 26, 2016 08:40
-
-
Save h0tk3y/73d74d6343ffda442b6cff1e4088f932 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
| 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