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?
For empty Queue use companion object:
val empty = Queue.empty[Int]
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With