Garden 🌻

List::index_of

If value is present in this list, return the index of the first instance.

["A", "B"].index_of("B") //-> Some(1)
["A", "B", "B"].index_of("B") //-> Some(1)
["A", "B"].index_of("C") //-> None
Source Codepublic method index_of<T>(this: List<T>, value: T): Option<Int> {
  for (i, v) in this.enumerate() {
    if v == value {
      return Some(i)
    }
  }

  None
}