> For the complete documentation index, see [llms.txt](https://3440217568.gitbook.io/rxswift/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://3440217568.gitbook.io/rxswift/decision_tree/single.md).

# single

**限制 `Observable` 只有一个元素，否出发出一个 `error` 事件**

![](https://4217506537-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MWj545abP2yK86-qksJ%2Fsync%2F4ebe2f27cd891615eac649e3875c75a06ebc264c.png?generation=1616819398843812\&alt=media)

**single** 操作符将限制 `Observable` 只产生一个元素。如果 `Observable` 只有一个元素，它将镜像这个 `Observable` 。如果 `Observable` 没有元素或者元素数量大于一，它将产生一个 `error` 事件。
