1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
use std.*; let generator = fn(()) { print "yielding 1"; yield "1"; print "yielding 2"; yield "2"; print "yielding stop"; yield "stop"; print "yielding 3"; yield "3"; }; for value in generator() { print value; if value == "stop" then ( break; ); };