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 -

performance - Why is XCHG reg, reg a 3 micro-op instruction on modern Intel architectures? -

jquery - Responsive Navbar with Sub Navbar -