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’.