Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@magdamiu
Created November 17, 2019 21:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save magdamiu/69f58c9faf51a37b28c68a9c8026995f to your computer and use it in GitHub Desktop.
Save magdamiu/69f58c9faf51a37b28c68a9c8026995f to your computer and use it in GitHub Desktop.
for with index
var languages = arrayOf("Java", "Kotlin", "Scala", "C#")
for (item in languages)
println(item)
var desserts = arrayOf("Cupcake", "Ice cream", "Eclair", "Pie")
for (item in desserts.indices) {
if (desserts[item].length > 4)
println(desserts[item])
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment