I am new to scala. I have created a scala object containing a couple of methods. I am trying to invoke the method from Scala REPL
but the import
statement is not working.
This is the code I tried (It is in a default package
):
object Hello extends App {
def sum(xs: List[Int]): Int = 0;
def max(xs: List[Int]): Int = 0;
}
For starting the Scala REPL
, I opened the console and then did the following:
Microsoft Windows [Version 6.1.7601]
Copyright (c) 2009 Microsoft Corporation. All rights reserved.
C:\Users\user>sbt
[info] Set current project to user (in build file:/C:/Users/user/)
> console
[info] Updating {file:/C:/Users/user/}user...
[info] Resolving org.fusesource.jansi#jansi;1.4 ...
[info] Done updating.
[info] Starting scala interpreter...
[info]
Welcome to Scala version 2.10.4 (Java HotSpot(TM) 64-Bit Server VM, Java 1.6.0_2
2).
Type in expressions to have them evaluated.
Type :help for more information.
scala> import Hello._
<console>:7: error: not found: value Hello
import Hello._
^
scala>
The project workspace and the project is created in E:/Work
. Even I tried navigating to the project and then followed the same steps above but it gives the same error.
Please let me know how to make this import
statement work from Scala REPL
.