On Tuesday, 24 August 2021 at 19:06:44 UTC, Alexandru Ermicioi wrote:
On Tuesday, 24 August 2021 at 09:15:23 UTC, bauss wrote:

A range should be a struct always and thus its state is copied when the foreach loop is created.

Actually the range contracts don't mention that it needs to be a by value type. It can also be a reference type, i.e. a class.


Of course it doesn't disallow classes but it's generally advised that you use structs and that's what you want in 99% of the cases. It's usually a red flag when a range starts being a reference type.

Reply via email to