Site menu

CodeCook.io

  • Languages
    • C
    • C++
    • CSS
    • Git
    • HTML
    • Java
    • JavaScript
    • jQuery
    • PHP
    • Python
    • Ruby
    • Scala
  • array
  • find

Scala - Find index of item in array

Calculate/get the index of an item in an array. In case of multiple occurrences return first occurrence.

0
2927
  • Share on Facebook
  • Share on Google+
  • Share on Twitter

Using indexWhere

Returns first occurrence of item in SeqLike
{{array}}.indexWhere( _ == {{item}})
java

Notes

last update: Oct. 28, 2014

Advertisement

This project is hosted on DigitalOcean, try it and support us

Related concept

  • Get first element array
  • Concatenate two arrays
  • Append item to array
  • Array length
  • Sort list of numbers

Other language

  • Python
  • JavaScript
  • jQuery

Random task

  • Loop until condition is true
  • Counter loop
  • Style external links
  • Remove user from group
  • Random element from queryset
  • Blog
  • About
  • License