0
Iteration question
fun f(x: String): Int { var z = 0 for(a in x) { z++ } return z } fun main(args: Array<String>) { println(f("hello")) } Answer ==> 5 I got the answer of the about statement right but would need a step by step explanation as to how (a ) plays a part here. I know (x) to be the param of the function (f) but couldn't get (a)
1 ответ
+ 1
Habibu Mamudu 🇬🇭
'a' is a each value of string 'x'
if you print that, each character of string would be print.