You can use indexOf

times.indexOf(Some("Last month")) // returns 1

Update

You can convert the times ArrayBuffer[Option[String]] into a ArrayBuffer[String] via

val l = times.map(_.getOrElse("")) // ArrayBuffer("Last week", "Last month", ...)

And then you can search for the strings

l.indexOf("Last month")
Answer from Till Rohrmann on Stack Overflow
🌐
Scala Documentation
docs.scala-lang.org › overviews › scala-book › arraybuffer-examples.html
The ArrayBuffer Class | Scala Book | Scala Documentation
This page provides examples of how to use the Scala ArrayBuffer class, including adding and removing elements.
🌐
Scala Programming Language
scala-lang.org › api › current › scala › collection › mutable › ArrayBuffer.html
ArrayBuffer
the element to add. Returns · the array buffer itself · Source · ArrayBuffer.scala · def apply(n: Int): A · Gets the element at the specified index. This operation is provided for convenience in Seq. It should not be assumed to be efficient unless you have an IndexedSeq.
🌐
GeeksforGeeks
geeksforgeeks.org › scala › scala-arraybuffer
Scala | ArrayBuffer - GeeksforGeeks
March 5, 2019 - Array in scala is homogeneous and mutable, i.e it contains elements of the same data type and its elements can change but the size of array size can’t change. To create a mutable, indexed sequence whose size can change ArrayBuffer class is used. To use, ArrayBuffer, scala.collection.mutable.ArrayBuffer class is imported, an instance of ArrayBuffer is created.
🌐
Baeldung
baeldung.com › home › scala collections › guide to arraybuffer
Guide to ArrayBuffer | Baeldung on Scala
March 18, 2024 - ArrayBuffer allows us to insert a new element both at the beginning and end of the list. Furthermore, since it’s an indexed list, it’s also easy to insert an element in any position of the list.
🌐
Allaboutscala
allaboutscala.com › tutorials › chapter-7-beginner-tutorial-using-scala-mutable-collection › scala-tutorial-learn-use-mutable-arraybuffer
Scala Tutorial - Learn How To Use Scala's Mutable ArrayBuffer
February 3, 2020 - In this Scala beginner tutorial, you will learn how to use Scala's Mutable ArrayBuffer: initialize, access element at specific index, add, remove elements.
🌐
TutorialsPoint
tutorialspoint.com › scala_collections › scala_collections_arraybuffer.htm
Scala Collections - ArrayBuffer
In case underlying array is full then a new larger array is created and all elements are copied to larger array. The following is the syntax for declaring an ArrayBuffer variable. ... Here, z is declared as an array-buffer of Strings which is initially empty. Values can be added by using commands like the following − ... import scala.collection.mutable.ArrayBuffer object Demo { def main(args: Array[String]) = { var myList = ArrayBuffer("Zara","Nuha","Ayan") println(myList); // Add an element myList += "Welcome"; // Add two element myList += ("To", "Tutorialspoint"); println(myList); // Remove an element myList -= "Welcome"; // print second element println(myList(1)); } }
Find elsewhere
🌐
Scala-lang
nightly.scala-lang.org › api › scala › collection › mutable › ArrayBuffer.html
ArrayBuffer
Add s a single element to this array buffer. ... Gets the element at the specified index. This operation is provided for convenience in Seq.
🌐
EDUCBA
educba.com › home › software development › software development tutorials › scala tutorial › scala arraybuffer
Scala ArrayBuffer | Learn the Working for ArrayBuffer in Scala
June 6, 2023 - // We define the datatype whatever we want to use over making a scala Array Buffer. It can be int, String, double, etc. ArrayBuffer contains the array’s size and the elements in that Array.
Address: Unit no. 202, Jay Antariksh Bldg, Makwana Road, Marol, Andheri (East),, 400059, Mumbai
🌐
Otfried
otfried.org › scala › arraybuffer.html
Scala Documentation -- ArrayBuffer
You can add elements using +=. When you are done, the toArray method returns the contents as a normal array. scala> val A = scala.collection.mutable.ArrayBuffer.empty[Int] A: scala.collection.mutable.ArrayBuffer[Int] = ArrayBuffer() scala> A += 1 res9: A.type = ArrayBuffer(1) scala> for (i ...
🌐
Hello-scala
hello-scala.com › 201-scala-arraybuffer-examples.html
hello-scala.com - hello scala المصادر والمعلومات.
hello-scala.com هل هو أول وأفضل مصادر جميع المعلومات التي تبحث عنها. من ضوء الموضوعات العامة إلى مزيد من الموضوعات التي كنت لتتوقعها هنا، hello-scala.com تمتلكها جميعًا.
🌐
Scala Programming Language
scala-lang.org › api › 2.13.x › scala › collection › mutable › ArrayBuffer.html
Scala Standard Library 2.13.18 - scala.collection.mutable.ArrayBuffer
February 13, 2011 - a new collection of type CC[B] which contains all elements of this array buffer followed by all elements of suffix. ... Gets the element at the specified index.
🌐
GitHub
github.com › scala › docs.scala-lang › blob › main › _overviews › scala-book › arraybuffer-examples.md
docs.scala-lang/_overviews/scala-book/arraybuffer-examples.md at main · scala/docs.scala-lang
You remove elements from an ArrayBuffer with the -= and --= methods: // remove one element nums -= 9 // remove multiple elements nums -= 7 -= 8 // remove multiple elements using another collection nums --= Array(5, 6) Here’s what all of those examples look like in the REPL: scala> import scala.collection.mutable.ArrayBuffer scala> val nums = ArrayBuffer(1, 2, 3) val nums: ArrayBuffer[Int] = ArrayBuffer(1, 2, 3) scala> nums += 4 val res0: ArrayBuffer[Int] = ArrayBuffer(1, 2, 3, 4) scala> nums += 5 += 6 val res1: ArrayBuffer[Int] = ArrayBuffer(1, 2, 3, 4, 5, 6) scala> nums ++= List(7, 8, 9) va
Author: scala