+ 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?
2 Réponses
+ 7
call the function (line 20 change.)
https://code.sololearn.com/cp2FzkS47MWd
+ 17
John Wells thank you very much sir!