[SOLVED] How can I change ()->Boolean to Boolean? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 18

[SOLVED] How can I change ()->Boolean to Boolean?

fun main(args: Array<String>){ var n=123 if(n.sum()){ print("true") }else{ print("false") } } fun Int.sum()={ var s=0 for(c in this.toString()){ s+=c.toInt()-'0'.toInt() } s==this } if you try to run this code the output won't be false but an error because it cannot convert ()->Boolean to Boolean.... How can I make this work?

26th Jun 2018, 9:40 AM
Uni
Uni - avatar
2 Answers
+ 7
call the function (line 20 change.) https://code.sololearn.com/cp2FzkS47MWd
26th Jun 2018, 10:23 AM
John Wells
John Wells - avatar
+ 17
John Wells thank you very much sir!
26th Jun 2018, 10:24 AM
Uni
Uni - avatar