Here is a Pattern matching switch case in Scala, which basically matches different data types of the selector variable to the corresponding case variable and does some manipulation on it
def valueToString(x: Any): String = x match {
case d: BigDecimal =>
/* do something here */
case a: Array[Byte] =>
new String(a, "UTF-8")
case s: Seq[_] =>
/*do something here */
case m: Map[_,_] =>
/*do something here */
case d: Date =>
/*do something here */
case t: Timestamp =>
/*do something here */
case r: Row =>
/*do something here */
}
Python does not have exactly support this kind of pattern matching. I know about switcher in Python, but it expects either regex or actual matching of the variable. How do i achieve the above functionality in Python
d,a,s,m... - regex constants?