http://scala-programming-language.1934581.n4.nabble.com/Including-one-script-in-another-td1935355.html On Mon, Feb 23, 2009 at 12:01:21PM -0600, Dean Wampler wrote: > Is it possible to include/invoke one Scala script in another? I haven't > found a way. Runtime.getRuntime.exec("scala -i " + script) Okay, maybe not exactly what you wanted, although it does meet the "invoke" test. I am looking over related stuff so if you want to outline exactly what you'd hope to achieve I will see what I can do. ----------------- http://stackoverflow.com/questions/1529434/how-to-split-a-scala-script-into-multiple-files Used as a scripting language, does Scala have some sort of include directive, or is there a way to launch a script from an other script ? The scala command has the :load filename command to load a Scala file interactively. Alternatively the scala command's -i filename argument can be used to preload the file. ---------------------- http://stackoverflow.com/questions/13898373/how-to-load-a-scala-file-in-the-sbt-console In short, use the :load function in the scala REPL to load a file. Then you can call that function in the file if you wrap it in an object or class since sbt tries to compile it. Not sure if you can do it with just a function definition. Wrap it in an object to get sbt to compile it correctly. object Times{ def timesTwo(i: Int): Int = { println("hello world") i * 2 } } Load the file: scala> :load Times.scala Loading Times.scala... defined module Times Then call timesTwo in Times: scala> Times.timesTwo(2) hello world res0: Int = 4 If you want just the function definition without wrapping it in a class or object the you can paste it with the command :paste in the scala REPL/sbt console. scala> :paste // Entering paste mode (ctrl-D to finish) def timesTwo(i: Int): Int = { println("hello world") i * 2 } // Exiting paste mode, now interpreting. timesTwo: (i: Int)Int This can be called by just the function name. scala> timesTwo(2) hello world res1: Int = 4 share|improve this answer -------------------------------- SEE ALSO: :paste at http://docs.scala-lang.org/scala/2.11/