I'm working on an exercise. I need to create a java project that can be run from the scala command line. The final output should be this:
scala> int2str(6)
res0: String = six
scala> int2str(65)
res0: String = sixty-five
How do I create a function that can be accessed by scala like that? I can create a Scala project in IntelliJ, but I don't know how to export that function to be used like that.
Any help is appreciated.
Thanks
Assuming you have the following scala code:
You can just make a jar file from your scala project with a command
sbt packagefor instance, then runscala -cp <your jar>. In the scala console just import your function: