How to represent all values of a given type in Scala -


i try design trait condition filtering purpose, , need way represent values of given type.

  sealed trait condition[+a]   case object extends condition[nothing]   case class in[a](values : set[a]) extends condition[a]    def match_?[t](conditions: set[condition[t]])(v: any)(implicit tag: classtag[t]) =     tag.runtimeclass.isassignablefrom(v.getclass)    val allstring : set[condition[string]] = set(all)   val alltuples : set[condition[tuple2[_, _]]] = set(all)    println(match_?(allstring)("toto")) // should return true   println(match_?(allstring)(2)) // should return false    println(match_?(alltuples)("toto")) // should return false   println(match_?(alltuples)((1,2))) // should return true 

i'm not used reflection in scala. idea improve ? there better way achieve ?

[update] should use classtag or typetag in case.


Comments

Popular posts from this blog

php - Wordpress website dashboard page or post editor content is not showing but front end data is showing properly -

javascript - Get parameter of GET request -

javascript - Twitter Bootstrap - how to add some more margin between tooltip popup and element -