list of type parameter in trait scala -


trait mytrait[t]{   def mylist[t] =listbuffer.empty   def add(ele:t)= mylist::ele   def get:t=mylist } 

i want create list , add elements inside list , return list

i getting compile error.

update

any alternative use list instead of list buffer

you're shadowing trait level t in mylist. remove type parameter method:

def mylist = listbuffer.empty[t] 

Comments

Popular posts from this blog

Is there a better way to structure post methods in Class Based Views -

Qt QGraphicsScene is not accessable from QGraphicsView (on Qt 5.6.1) -

What is happening when Matlab is starting a "parallel pool"? -