score:3

Accepted answer

indexof can return -1 (str can contain not only latin letters).

  /** finds index of first occurrence of some value in this $coll.
   *
   *  @param   elem   the element value to search for.
   *  @tparam  b      the type of the element `elem`.
   *  @return  the index of the first element of this $coll that is equal (as determined by `==`)
   *           to `elem`, or `-1`, if none exists.
   *
   *  @usecase def indexof(elem: a): int
   *    @inheritdoc
   *
   *    $maynotterminateinf
   *
   */
  def indexof[b >: a](elem: b): int = indexof(elem, 0)

Related Query

More Query from same tag