I think what I'm trying to do is pretty obvious. For every character in a string1, print something using patter matching. (I have string2 there because I will use pattern matching of string1 to do something to string 2 and return String 2)
For some reason my code only prints out "()".
Also how do I make sure that my code returns a String. When I put the code in terminal it says: (string1: String)String => Unit , how do I make it say (string1: String)String => String
def stringPipeline(string1: String) = (string2: String) => {
for(c <- string1) {
c match {
case 'u' => "Upper Case"
case 'r' => "reverse"
case _ => "do something"
}
}
}
EDIT:
I would just like to point out what I wanted to do with string2:
def stringPipeline(string1: String) = (string2: String) => {
for(c <- string1) yield {
c match {
case 'U' => string2.toUpperCase
case 'r' => string2.reverse } } }
But it's return a vector/list of strings. I want all those cases to work on the same string2 object. So if I test the method on "hello", it should return "OLLEH".
Thanks