Unresolved reference: num1 in Kotlin, How to fix this error?

All QuestionsCategory: KotlinUnresolved reference: num1 in Kotlin, How to fix this error?
chetan shidling asked 4 years ago

Here is the code:
 
fun main(args : Array<String>){
add(41,22)
}
fun add(num1 : Int, num2 : Int){
println(“The sum is :” num1 + num2)
}

1 Answers
Krishna answered 4 years ago

Put $ symbol and run the code. Ok, I will try and share.
 
Code:
 
fun main(args : Array<String>){
add(41,22)
}
fun add(num1 : Int, num2 : Int){
println(“The sum is : ${num1 + num2}”)
}
 
Output:
 
The sum is : 63