Help me for excercise scala please

hello I am new to scala I would like to have the function indexOf() to create a function def
splitItem(content:String):(String,String,String) that takes the
string contained and returns a 3-tuple comprising respectively:
the beginning of the chain to ;
the chain between and ;
the string after (NB: the indexOf() function returns the
position of the beginning of the string sought).

I would highly recommend at least outlining your problem in Scastie to make it easier for volunteers to assist you.

For example, it appears you either left out a parameter (the String being sought) when defining your function, or you are attempting to create a String extension function. If you were to mock up the shape of the code in Scastie, the missing code would likely have become apparent.

Is this the shape of the code you are attempting to explore?

def splitItem(content: String, sought: String): (String, String, String) = {
  (???, sought, ???)
}

Here’s a link to this code directly in Scastie:

If so, then here’s one possible answer:

1 Like

this the form a function a chain that takes the
string contained and returns a 3-tuple

def splitItem(content: String): (String, String, String) = {
(???, sought, ???)
}

a chain that takes the
string contained and returns a 3-tuple

def splitItem (contenu : chaîne) : (chaîne, chaîne, chaîne) = {
(???, recherché, ???)
}

thank’s

1 Like