Search is based on content in memory. And it loads only after calling toList .
What is the best way to see directly from source . Source.fromFile returns a scala.io.BufferedSource . getLines returns a BufferedLineIterator .
Here in BufferedLineIterator the contents of the files are read.
override def hasNext = { if (nextLine == null) nextLine = lineReader.readLine nextLine != null } override def next(): String = { val result = { if (nextLine == null) lineReader.readLine else try nextLine finally nextLine = null } if (result == null) Iterator.empty.next else result } }
To call the toList list toList use next and hasNext above. So lst already contains all the elements of the file.
Running lst.contains(x) through the list like any other list.
source share