New to scala, and can\'t seem to get my match expression to work. I\'ve read about the differences between how the statement is evaluated (e.g. a new variable as opposed to one
Either of these would work:
// declared inside of object
val numberOne = "+17201234567"
val numberTwo = "+17201235678"
def returnSomething(number: String): String = number match {
case `numberOne` => "my first number"
case `numberTwo` => "my second number"
case _ => "a default number"
}
// declared inside of object
val NumberOne = "+17201234567"
val NumberTwo = "+17201235678"
def returnSomething(number: String): String = number match {
case NumberOne => "my first number"
case NumberTwo => "my second number"
case _ => "a default number"
}
But you said you tried and it did not work. So, what exactly went wrong?