Finding the index of an element in a list scala

list, scala

Solution

scala> List("Mary", "had", "a", "little", "lamb").indexOf("little")
res0: Int = 3

You might try reading the scaladoc for List next time. ;)

Problem

How do I find the index of an element in a Scala list. ``` val ls = List("Mary", "had", "a", "little", "lamb") ``` I need to get 3 if I ask for the index of "little"

Original source

Related problems