Write a function add
, which takes two integer variables x
and y
and returns their sum as output in which y is an implicit parameter
, and also declares the implicit parameter in the main function as 7
. Then, write a function greet
which takes two strings s1
and s2
, where s1 is an implicit parameter with value as Name
. On taking the string input from the command line, the program must print s1 : s2
(refer to the example at the end for more clarity).
Copy the following ImplicitParams2 program into the file: `object ImplicitParams2 extends App {
val input1 : String = args(0)
val input2 : Int = args(1).toInt
//write your code here
println(greet(input1))
println(add(input2))
}
i done the following code:
object ImplicitParams2 extends App {
val input1 : String = args(0)
val input2 : Int = args(1).toInt
def add(x:Int=input2)(implicit y:Int=7)=x+y
def greet(s2:String=input1)(implicit s1:String=“Name”) = s1:s2
println(greet(input1))
println(add(input2))
}