functional programming - Scala throws no type parameters error on valid lambda definition -


the following method definition:

  def validclasses(datatype: datatype) = {     examples       .flatmap {         v: =>           try {             val canon = tocanonicaltype(v, datatype)             canon.getclass           }             .tooption             .toset       }   } 

yield following error:

error:(94, 8) no type parameters method flatmap: (f: => scala.collection.gentraversableonce[b])(implicit bf: scala.collection.generic.canbuildfrom[scala.collection.immutable.set[any],b,that])that exist can applied arguments (any => scala.collection.immutable.set[class[?0]] forsome { type ?0 })  --- because --- argument expression's type not compatible formal parameter type;  found   : => scala.collection.immutable.set[class[?0]] forsome { type ?0 }  required: => scala.collection.gentraversableonce[?b]       .flatmap {    ^ 

which strange. result of toset not a set[class[?0]] forsome { type ?0 }. there way fix problem?

as result of toset not a set[class[?0]] forsome { type ?0 }.

yes, is: .getclass returns class[_], try { ... } try[class[?0]] forsome { type ?0 } (?0 variable name generated compiler), , .tooption.toset set[class[?0]] forsome { type ?0 }.


Comments

Popular posts from this blog

wordpress - (T_ENDFOREACH) php error -

Export Excel workseet into txt file using vba - (text and numbers with formulas) -

Using django-mptt to get only the categories that have items -