Skip to content

Instantly share code, notes, and snippets.

@ctrueden
Created March 16, 2017 20:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ctrueden/fe6cf043a36f777cdf34f410cc5ff9ff to your computer and use it in GitHub Desktop.
Save ctrueden/fe6cf043a36f777cdf34f410cc5ff9ff to your computer and use it in GitHub Desktop.
Kotlin in the SciJava REPL, using jrun (https://github.com/ctrueden/jrun)
$ jrun -u org.scijava:scijava-common:org.scijava.script.ScriptREPL+org.scijava:scripting-kotlin:0.1.0-SNAPSHOT
Welcome to the SciJava REPL!
Available built-in commands:
:help | this handy list of commands
:vars | dump a list of variables
:lang <name> | switch the active language
:langs | list available languages
:debug | toggle full stack traces
:quit | exit the REPL
Or type a statement to evaluate it with the active language.
Have fun!
language -> Kotlin
> 1+2
warning: some JAR files in the classpath have the Kotlin Runtime library bundled into them. This may cause difficult to debug problems if there's a different version of the Kotlin Runtime library in the classpath. Consider removing these libraries from the classpath or use '-Xskip-runtime-version-check' to suppress this warning
warning: library has Kotlin runtime bundled into it
3
> 4+5
9
> val x = 9*6
<null>
> x
54
> var y = 23*4.2
<null>
> y
96.60000000000001
> io
Error: error: unresolved reference: io
io
^
> bindings["io"]
org.scijava.io.DefaultIOService [priority = 0.0]
> val clown = bindings["io"].open("/Users/curtis/data/clown.png")
Error: error: unresolved reference: open
val clown = bindings["io"].open("/Users/curtis/data/clown.png")
^
> bindings["exportedVar"] = "Important information"
Error: error: unresolved reference. None of the following candidates is applicable because of receiver type mismatch:
@InlineOnly public operator inline fun <K, V> MutableMap<String, String>.set(key: String, value: String): Unit defined in kotlin.collections
@InlineOnly public operator inline fun StringBuilder /* = StringBuilder */.set(index: Int, value: Char): Unit defined in kotlin.text
bindings["exportedVar"] = "Important information"
^
error: no set method providing array access
bindings["exportedVar"] = "Important information"
^
> bindings.put("exportedVar", "Important information")
Error: error: unresolved reference: put
bindings.put("exportedVar", "Important information")
^
> kajshdfkashdfkajshdfkfsck
Error: error: unresolved reference: kajshdfkashdfkajshdfkfsck
kajshdfkashdfkajshdfkfsck
^
> %
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment