Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Creating a Queue in Scala

Tags:

scala

queue

I am trying to create a Queue in Scala by doing:

import scala.collection.immutable.Queue

val empty = new Queue[Int]

However I am getting an error stating that the Queue constructor is protected. If this is the case, am I missing something? All the Queue methods seem to be defined and working. Must I really extend the Queue class for no reason just to use a Queue?

like image 421
providence Avatar asked Oct 02 '11 20:10

providence


1 Answers

For empty Queue use companion object:

val empty = Queue.empty[Int]
like image 114
om-nom-nom Avatar answered Oct 08 '22 12:10

om-nom-nom