Scala's match/case for Option[classOf[...]] -


i need check returned type method invoke different methods. code:

class x ... class y ...  ...  def gettype(input:string) : option[class[_]] = {   if ... return some(classof[x])   if ... return some(classof[y])   ... }  gettype(input) match {   case some(classof[x]) => ... // error   case some(classof[y]) => ...   case none => ... } 

however, got errors:

enter image description here

what might wrong?

i think can't use classof inside structural match. instead can add condition checks that.

val opt: option[class[_]] = some(classof[int])  opt match {   case some(c) if c == classof[string] => "string"   case some(c) if c == classof[int] => "int"   case none => "no class"   case _ => "some other class" } //yields int 

Comments

Popular posts from this blog

javascript - Jquery show_hide, what to add in order to make the page scroll to the bottom of the hidden field once button is clicked -

javascript - Highcharts multi-color line -

javascript - Enter key does not work in search box -