diff --git a/docs/uts/buildin-object-api/iterable.md b/docs/uts/buildin-object-api/iterable.md index 28c77f62480b86ae7ee22882c0027efb7da59412..f4d8172aae2b3d4cd31d6300683794626bb6f22e 100644 --- a/docs/uts/buildin-object-api/iterable.md +++ b/docs/uts/buildin-object-api/iterable.md @@ -226,25 +226,25 @@ for (item of test) { ```typescript class TestClass implements UTSValueIterable { - - holderArray: (any | null)[] = [11, 22, null, 33, 44, null] - - valueIterator(): UTSIterator { - let holderIndex = 0; - let obj: UTSIterator = { - - next: () : UTSIteratorResult => { - const done = holderIndex == this.holderArray.length - return { - done, - value: done ? null : this.holderArray[holderIndex++], - } as UTSIteratorResult + + holderArray: (any | null)[] = [11, 22, null, 33, 44, null] + + valueIterator(): UTSIterator { + let holderIndex = 0; + let obj: UTSIterator = { + + next: () : UTSIteratorResult => { + const done = holderIndex == this.holderArray.length + return { + done, + value: done ? null : this.holderArray[holderIndex++], + } as UTSIteratorResult + } } + return obj } - return obj + } - -} ``` 执行结果: @@ -268,28 +268,30 @@ item null ```typescript -class TestClass implements UTSValueIterable { - - holderArray: (any | null)[] = [11, 22, null, 33, 44, null] - - valueIterator(): UTSIterator { - let holderIndex = 0; - let arr = this.holderArray.filter((value) => { - return value != null - }) - - let obj: UTSIterator = { - next: () : UTSIteratorResult => { - const done = holderIndex == arr.length - return { - done, - value: done ? null : arr[holderIndex++], - } as UTSIteratorResult + class TestClass implements UTSValueIterable { + + holderArray: (any | null)[] = [11, 22, null, 33, 44, null] + + valueIterator(): UTSIterator { + let holderIndex = 0; + let arr = this.holderArray.filter((value) => { + return value != null + }) + + let obj: UTSIterator = { + + next: () : UTSIteratorResult => { + const done = holderIndex == arr.length + return { + done, + value: done ? null : arr[holderIndex++], + } as UTSIteratorResult + } } + return obj } - return obj + } -} ```