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
Post a Comment