Skip to content

Commit 587c2b3

Browse files
committed
Document Sequence::single()
1 parent 4abe940 commit 587c2b3

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

ChangeLog.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,15 @@ Data sequences change log
33

44
## ?.?.? / ????-??-??
55

6+
* Introduce dedicated `util.data.NoSuchElement` exception. It's thrown
7+
from `Optional::get()` if no element is present instead of the generic
8+
`util.NoSuchElementException`. For BC reasons, it extends the latter.
9+
(@thekid)
10+
* Implemented PR #54: Implement `Sequence::single()` - which is similar
11+
to `first()` but raises an exception if there are more than 1 element
12+
in the sequence.
13+
(@thekid)
14+
615
## 10.0.0 / 2021-10-21
716

817
* Implemented xp-framework/rfc#341, dropping compatibility with XP 9

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@ The following operations return a single value by consuming all of the sequence:
109109
* **toArray** - will return a PHP array with zero-based keys
110110
* **toMap** - will return a PHP associative array
111111
* **first** - will return the first element as an `util.data.Optional` instance. A value will be present if the sequence was not empty.
112+
* **single** - like `first()`, but raises an exception if more than one element is contained in the sequence.
112113
* **count** - will return the number of elements in the sequence
113114
* **min** - returns the smalles element. Compares numbers by default but may be given a comparator function or a `util.Comparator` instance.
114115
* **max** - same as `min()`, but returns the largest element instead.

0 commit comments

Comments
 (0)