[fine] Some resilience, a design improvement for iterator
This commit is contained in:
parent
15548afc38
commit
f2e82942df
4 changed files with 29 additions and 8 deletions
|
|
@ -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
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue