Is it possible to match types in Scala? Something like this: (but it's compiled, obviously :)) Or maybe the right way is overloaded ?? Is this possible? Unfortunately, I can not give an example of an object and pattern match on it. You can use the manifest and match a pattern on them. When the problem of passing an array class is problematic, because as JVM uses a different class for each array type. To work around this problem, you can check whether a class in question is erased in the array or not: def [T] = T match {case String = & gt; "You gave me a string", Case Array = & gt; "You gave me an array" case _ = & gt; "I do not know how it is!" }
Comments
Post a Comment