> 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/startwith.md).

# startWith

**将一些元素插入到序列的头部**

![](/files/-MWlwQPheYUO2OfuJ3Ol)

**startWith** 操作符会在 `Observable` 头部插入一些元素。

（如果你想在尾部加入一些元素可以用[concat](/rxswift/decision_tree/concat.md)）

## 演示

```swift
let disposeBag = DisposeBag()

Observable.of("🐶", "🐱", "🐭", "🐹")
    .startWith("1")
    .startWith("2")
    .startWith("3", "🅰️", "🅱️")
    .subscribe(onNext: { print($0) })
    .disposed(by: disposeBag)
```

**输出结果：**

```swift
3
🅰️
🅱️
2
1
🐶
🐱
🐭
🐹
```
