私が読んだことから、
yield return <value>
行が実行された瞬間に関数から飛び出します。しかし、スコット・ガスリーのテキストは、
var errors = dinner.GetRuleViolations();
GetRuleViolations は長いリストですが、すべてのルール違反のリストを正常に取得します。
if(String.someFunction(text))
yield return new RuleViolation("Scary message");
if(String.anotherFunction(text))
yield return new RuleViolation("Another scary message");
これはどのように作動しますか?