Need Help to Understandinmg Scala Pattern MatchingType Problem

takes an integer input from command line. Based on the input, write a code for two match cases. In the first case based on the input1 from command line, convert initial to integer if input is 1 , double if input is 2 , and ‘String’ for any other input, and assign it to change . In the second match case based on type of change, print Integer is given if integer , Double is given if double and String is given if String .

object PatternMatching{
def main(args :Array[String]){
val input1 = args(0).toInt
val initial = “12345”
var change : Any = 0
// code
println(change.getClass)
}
I have recently begun to learn Scala Programming and I am trying to solve the above problem
Can someone please assist me with the first case i am not able to understand how to convert initial to integer , double and ‘String’.

And what problem do you have? What have you tried? What is blocking you?

Check out the below links:

https://alvinalexander.com/scala/scala-match-case-expressions-syntax-examples/

1 Like

Thankou! @monojeetdebnath. That links 're really helpful. My problem is solved now.