Can I use nested type in Scala generic function? -


how can use nested type in scala generic function ? i'd implement this

implicit def basicdblist2list[list[a]](value : basicdblist) = value.tolist.asinstanceof[list[a]] 

compiler gives following error:

scala: not found: type   implicit def basicdblist2list[list[a]](value : basicdblist) = value.tolist.asinstanceof[list[a]]                                                                                                ^ 

when write:

implicit def basicdblist2list[list[a]](value: basicdblist) = ... 

... doesn't mean think means. you're declaring new type parameter called list, not referring existing list trait in library! you're declaring newly-defined list type requires type parameter, you've called a, can't reference it.

what meant was:

implicit def basicdblist2list[a](value: basicdblist): list[a] = ... 

... says that, type a, can convert basicdblist list[a].

this sketchy code, though, 2 reasons:

  1. what type basicdblist class contain? not possible a. you'll classcastexception @ runtime.
  2. why want implicit conversion basicdblist list[a]? that's bad idea.

Comments

Popular posts from this blog

c# - Send Image in Json : 400 Bad request -

javascript - addthis share facebook and google+ url -

ios - Show keyboard with UITextField in the input accessory view -