Q263
The code below shows a typical way to show both index and value in many languages, including Kotlin. Which line of code shows a way to get both index and value more idiomatically? var ndx = 0; for (value in 1..5) println(" ndx - value") ndx++
A.
for( (ndx, value) in (1..20).withIndex() ){
AnswerB.
for( (ndx, value) in (1..20).pair() ){
C.
for( Pair(ndx, value) in 1..20 ){
D.
for( (ndx, value) in *(1..20) ){
Answer: Option A
Solution
Answer: Option A
No explanation is given for this question Let's Discuss on Board