提交 ce5468ff 编写于 作者: 杜庆泉's avatar 杜庆泉

Update iterable.md

上级 6ff48864
......@@ -244,7 +244,7 @@ class TestClass implements UTSValueIterable<any | null> {
return obj
}
}
}
```
执行结果:
......@@ -268,28 +268,30 @@ item null
```typescript
class TestClass implements UTSValueIterable<any> {
class TestClass implements UTSValueIterable<any | null> {
holderArray: (any | null)[] = [11, 22, null, 33, 44, null]
valueIterator(): UTSIterator<any> {
valueIterator(): UTSIterator<any | null> {
let holderIndex = 0;
let arr = this.holderArray.filter((value) => {
return value != null
})
let obj: UTSIterator<any> = {
next: () : UTSIteratorResult<any> => {
let obj: UTSIterator<any | null> = {
next: () : UTSIteratorResult<any | null> => {
const done = holderIndex == arr.length
return {
done,
value: done ? null : arr[holderIndex++],
} as UTSIteratorResult<any>
} as UTSIteratorResult<any | null>
}
}
return obj
}
}
}
```
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册