@@ -357,6 +357,24 @@ trait IterableOnceOps[+A, +CC[_], +C] extends Any { this: IterableOnce[A] =>
357
357
def take (n : Int ): C
358
358
359
359
/** Takes longest prefix of elements that satisfy a predicate.
360
+ *
361
+ * The matching prefix starts with the first element of this $coll,
362
+ * and the element following the prefix is the first element that
363
+ * does not satisfy the predicate. The matching prefix may empty,
364
+ * so that this method returns an empty $coll.
365
+ *
366
+ * Example:
367
+ *
368
+ * {{{
369
+ * scala> List(1, 2, 3, 100, 4).takeWhile(n => n < 10)
370
+ * val res0: List[Int] = List(1, 2, 3)
371
+ *
372
+ * scala> List(1, 2, 3, 100, 4).takeWhile(n => n == 0)
373
+ * val res1: List[Int] = List()
374
+ * }}}
375
+ *
376
+ * Use [[span ]] to obtain both the prefix and suffix.
377
+ * Use [[filter ]] to retain only those elements from the entire $coll that satisfy the predicate.
360
378
* $orderDependent
361
379
* @param p The predicate used to test elements.
362
380
* @return the longest prefix of this $coll whose elements all satisfy
@@ -374,6 +392,25 @@ trait IterableOnceOps[+A, +CC[_], +C] extends Any { this: IterableOnce[A] =>
374
392
def drop (n : Int ): C
375
393
376
394
/** Drops longest prefix of elements that satisfy a predicate.
395
+ *
396
+ * The matching prefix starts with the first element of this $coll,
397
+ * and the element following the prefix is the first element that
398
+ * does not satisfy the predicate. The matching prefix may empty,
399
+ * so that this method returns the entire $coll.
400
+ *
401
+ * Example:
402
+ *
403
+ * {{{
404
+ * scala> List(1, 2, 3, 100, 4).dropWhile(n => n < 10)
405
+ * val res0: List[Int] = List(100, 4)
406
+ *
407
+ * scala> List(1, 2, 3, 100, 4).dropWhile(n => n == 0)
408
+ * val res1: List[Int] = List(1, 2, 3, 100, 4)
409
+ * }}}
410
+ *
411
+ * Use [[span ]] to obtain both the prefix and suffix.
412
+ * Use [[filterNot ]] to drop all elements that satisfy the predicate.
413
+ *
377
414
* $orderDependent
378
415
* @param p The predicate used to test elements.
379
416
* @return the longest suffix of this $coll whose first element
0 commit comments