Given code:
val test = List(1, 2, 3)
printList[Int](test.dropWhile((a: Int) => {a == 1}))
And it will print correctly: 2 3
While using code like this:
val test = List(1, 2, 3)
printList[Int](test.dropWhile((a: Int) => {a == 2}))
And it will print incorrectly: 1 2 3
And so does a == 3
How do I use dropWhile
appropriately?
well, I figure out that dropWhile return "the longest suffix of this list whose first element does not satisfy the predicate p." So if I want to detele some elements satisfy predicate p, I have to use filterNot : )