Iterating list

The user's list that we have passed inside the JSON object will be iterated and rendered on the page. Kotlin has a variety of ways to iterate over the list. Actually, anything that implements iterable can be represented as a sequence of elements that can be iterated. It has a lot of utility functions, some of which are mentioned in the following list:

  • hasNext(): This returns true if the iteration has more elements
  • hasPrevious(): This returns true if there are elements in the iteration before the current element
  • next(): This returns the next element in the iteration
  • nextIndex(): This returns the index of the element that would be returned by a subsequent call to next
  • previous(): This returns the previous element in the iteration ...

Get Kotlin Blueprints now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.