Exercice questions 3 scala don't run help me please

question say
The rows of data are separated from one another by returns to the ‘‘n’’ line.
Use the ‘split()’ function to transform the string from the analysis of ‘’ into a list of rows.

Create a function ‘def filterDataset(lines:Seq[String]):Seq[String]’, using the ‘filter()’ function that applies to strings to retrieve only rows that contain the string ‘<dataset:’.

i did
def filterDataset(lines:Seq[String]):Seq[String]=

val fil = lines.filter( x=> x.contentEquals("<dataset:"))

but don’t run

Hello gafy,

I think you want to use startsWith instead:

def filterDataset(lines: Seq[String]): Seq[String] =
  lines.filter(line => line.startsWith("<dataset:"))

Even shorter:

def filterDataset(lines: Seq[String]): Seq[String] =

Maybe I’m misunderstanding the problem statement, which says retrieve only rows that contain the string ‘<dataset:’. but from the picture you posted it looks like ‘<dataset:’ is always occurring at the beginning of those lines.

Anyway, if there are lines that do NOT start with ‘<dataset:’ but contain ‘<dataset:’ further down the line, then you can use .contains() instead of startsWith:

def filterDataset(lines: Seq[String]): Seq[String] =