Question: 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?
- `for( (ndx, value) in (1..20).withIndex() ){`
- `for( (ndx, value) in (1..20).pair() ){`
- `for( Pair(ndx, value) in 1..20 ){`
- `for( (ndx, value) in *(1..20) ){`
Answer: The correct answer of the above question is Option A:`for( (ndx, value) in (1..20).withIndex() ){`