Last active
August 29, 2015 13:57
-
-
Save tangentstorm/9761006 to your computer and use it in GitHub Desktop.
first attempt at using kotlin
This file contains 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
/** | |
* Created by michal on 3/25/2014. | |
*/ | |
import java.util.ArrayDeque | |
import java.util.Map; | |
import java.util.HashMap | |
trait WjData { | |
} | |
private class WjNull : WjData { | |
override fun toString() = "null" | |
} | |
class WjInt(val value : Int): WjData { | |
override fun toString() = value.toString() | |
} | |
class WjStr(val value :String) : WjData { | |
override fun toString() = '"' + super.toString() + '"' | |
} | |
class WjStack : ArrayDeque<WjData>(), WjData { | |
} | |
class WjDict : HashMap<WjStr, WjData>(), WjData { | |
} | |
public val WJNULL : WjData = WjNull() | |
fun main(args: Array<String>) { | |
val data = WjStack() | |
data.push(WJNULL) | |
data.push(WjInt(5)) | |
data.push(WjStack()) | |
print(data) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment