Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Too many arguments for public inline fun println(): Unit defined in kotlin.io

I am trying to make a simple program that let you add just two numbers (just learning basics) and i just "fell" to this problem:

GODCalculator.kt: (18, 15):Too many arguments for public inline fun
println(): Unit defined in kotlin.io

I tried to find some anwsers on internet, but didn’t find excatly what i wanted to…
nothing solved my issue

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

fun addition(){
println("So please insert two numbers, the program i mean the god will solve your math problem.")
print("Number #1: "); val z = readLine()!!.toInt()
print("\n")
print("Number #2: "); val c = readLine()!!.toInt()
val v = c+z
println(z," + " ,c, " = ",v)

Problem with:
println(z," + " ,c, " = ",v)

but i also tried with "+" edition like this:
println(z+" + "+c+" = "+v)

both didn’t work :/

I use:
IntelliJ IDEA Community Edition, but I don’t think it matters anyway
I am learning Kotlin on console, because when i tried to start use Android Studio i just got scared how many i have to know…

Edit:
Thanks to lpizzinidev.
His anwser totally fixed my issue…
The correct way is: println("$z + $c = $v")

>Solution :

You can use string interpolation:

println("$z + $c = $v")

If you want to use string concatenation you should first convert the integers to a string with .toString():

println(z.toString() + " + " + c.toString() + " = " + v.toString())

The former approach is more verbose.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading