Yield Return with Null

前端 未结 6 1761
长发绾君心
长发绾君心 2020-12-16 09:52

Is there any way to optionally return a null with a \"return yield\" driven iterator?

I would like to return a null in some cases and I don\'t think this is particul

6条回答
  •  夕颜
    夕颜 (楼主)
    2020-12-16 10:18

    This just isn't encouraged. When you're talking about a sequence, "null" should generally have the same semantics as "empty list."

    Also, it's impossible to design the language to work in the way you'd like it to work here without extra syntax, since what if you were to hit a "yield return [whatever]" and then a "return null?"

提交回复
热议问题