Created
July 29, 2010 01:10
-
-
Save nowelium/496933 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 hoge | |
import scala.tools.nsc.Interpreter | |
import scala.tools.nsc.InterpreterResults.Result | |
import scala.tools.nsc.Settings | |
class User(id:Int, name:String) { | |
def id():Int = { id } | |
def name():String = { name } | |
override def toString():String = { | |
"id: " + id + " name: " + name | |
} | |
} | |
object A { | |
def main(args: Array[String]): Unit = { | |
val s = new Settings(Console.println) | |
s.classpath.value = System.getProperty("java.class.path"); | |
val itpr = new Interpreter(s) | |
itpr.bind("user", "hoge.User", new User(1, "hoge")); | |
val r:Result = itpr.interpret(""" | |
Console.println("hello"); | |
Console.println(user) | |
Console.println("id =>" + user.id); | |
Console.println("name => " + user.name); | |
""") | |
println("result => " + r); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment