[fine] Some resilience, a design improvement for iterator

This commit is contained in:
John Doty 2024-01-29 10:04:47 -08:00
parent 15548afc38
commit f2e82942df
4 changed files with 29 additions and 8 deletions

View file

@ -83,16 +83,20 @@ fun more_examples(weapon: MeleeWeapon or RangedWeapon) -> f64 or () {
}
// Some fun with iterators
class Finished {}
let FINISHED = new Finished {}
class Iterator {
current: f64;
fun next(self) -> f64 or () {
fun next(self) -> f64 or Finished {
if self.current < 10 {
let result = self.current;
self.current = self.current + 1;
return result;
}
FINISHED
}
}