Created
December 6, 2019 02:46
-
-
Save pambrose/01528baed61547ef5411f687a800d45f to your computer and use it in GitHub Desktop.
Example of KtsScript
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
class IncClass(var i: Int = 9) { | |
fun inc() { | |
i++ | |
} | |
override fun toString() = "Value: $i" | |
} | |
fun main() { | |
KtsScript() | |
.apply { | |
add("v1", 55) | |
add("v2", "A String") | |
add("v3", IncClass()) | |
eval( | |
""" | |
println(v1) | |
println(v2) | |
println(v3) | |
repeat(10) { v3.inc() } | |
println(v3) | |
""" | |
) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment