simple problem using standard class

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

simple problem using standard class

Sven Eric Panitz
Hello all,
it seems I am doing something fundamentally wrong.

When I try to compile a simple class like:

class T{
  import scala.collection.mutable.HashSet
  val x= HashSet[String]()
}

I get the compiler error message:

error: class file  
/usr/local/share/scala/lib/scala-library.jar(scala/collection/mutable/HashSet.class)  
does not define object HashSet
one error found

Has anyone an idea of what is going on there.

greetings
Sven Eric

--
www.panitz.name
Reply | Threaded
Open this post in threaded view
|

Re: simple problem using standard class

Sven Eric Panitz
Ah, I found it:
I should have written:

>   val x= new HashSet[String]()

since skipping the new is only allowed for case classes.
(I never liked the keyword new in Java...)

Sven Eric

On Fri, 28 Apr 2006 13:25:37 +0200, Sven Eric Panitz <[hidden email]>  
wrote:

> Hello all,
> it seems I am doing something fundamentally wrong.
>
> When I try to compile a simple class like:
>
> class T{
>   import scala.collection.mutable.HashSet
>   val x= HashSet[String]()
> }
>
> I get the compiler error message:
>
> error: class file
> /usr/local/share/scala/lib/scala-library.jar(scala/collection/mutable/HashSet.class)
> does not define object HashSet
> one error found
>
> Has anyone an idea of what is going on there.
>
> greetings
> Sven Eric
>



--
www.panitz.name