The following code doesn't' work in scala shell, but it works in IDE, does anyone how can I use object type as method parameter in scala-shell, thanks.
scala> object A {
| }
defined object A
scala> def f(a:A) :Unit = {
| }
<console>:63: error: not found: type A
def f(a:A) :Unit = {
What do you mean by works in IDE? I created a project with one file,
HelloWorld1
, where its content is:When compiling I am getting the following error:
As mentioned in the two answers above, you can either do:
Or define trait instead of object: