I have a file with several lines of scala code -- imports, list value assignments, etc. that I often use to initialize some things when using the REPL.
Currently I just open up the file in a text editor and copy-and-paste it into the REPL, but is there a way to do it by calling the external file in a more direct manner so I don't have to copy-and-paste every time?
In some interactive database tools like SQL Plus, it is done by typing @filename
at the prompt. Is there something similar in the Scala REPL? Preceding the filename with @
doesn't work, eval
doesn't work either.
Type:
:help
and you see, that
:load <path> load and interpret a Scala file
solves your problem.
In some circumstances, pasting the code might be preferable though, but then
:paste
might be your friend then. It helps inserting a whole block without feedback, line by line, until you hit Ctrl + D. In some cases this is significant for the code interpretation.