I am trying to convert my way of getting values from Form
, but stuck some where
val os= for { m <- request.body.asFormUrlEncoded v <- m._2 } yield v
os
is scala.collection.immutable.Iterable[String]
and when i print it in console
os map println
console
sedet impntc sun job 03AHJ_VutoHGVhGL70
i want to remove the first and last element from it.
Use drop
to remove from the front and dropRight
to remove from the end.
def removeFirstAndLast[A](xs: Iterable[A]) = xs.drop(1).dropRight(1)
Example:
removeFirstAndLast(List("one", "two", "three", "four")) map println
Output:
two three
Another way is to use slice
.
val os: Iterable[String] = Iterable("a","b","c","d") val result = os.slice(1, os.size - 1) // Iterable("b","c")
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With