I am trying to use strings in a case class like java switch-case statements switch(someString). But scala match statement always resolves to the first block.
whichTopic match {
case accounts ⇒ {
logger.info("!!!! ---- FOR ACCOUNTS --- !!! ")
}
case users ⇒ {
logger.info("!!!! ---- FOR USERS --- !!! ")
// TODO : Handle errors from the consumer
}
}
Even when whichTopic value has users, it goes into the accounts block
case x =>will match all input becausexis an unbound variable that can hold any value being matched against.case accounts =>is the same. You're creating a variable namedaccountsthat can hold (and thus match) any value.