Skip to content

@Iterable / @IterateOver

Collection iteration — implement Symbol.iterator over a single @IterateOver field.

KindRuntime
Backendslegacy, stage3
Requires generateNo

Example

ts
import { Iterable, IterateOver } from 'lombok-typescript/legacy';

@Iterable
class Playlist {
  @IterateOver
  songs: string[] = ['a', 'b', 'c'];
}

for (const song of new Playlist()) {
  console.log(song);
}

Exactly one @IterateOver field is required per class.

Released under the MIT License.