On Monday, 5 August 2019 at 01:41:06 UTC, Ali Çehreli wrote:
Two examples with foreach and ranges. The 'ubyte.max + 1' expression is int. The compiler casts to ubyte (because we typed ubyte) in the foreach and we cast to ubyte in the range:

Maybe it was a bad example of my part (Using for), and indeed using foreach would solve that specific issue, but what I'm really looking for if there is a flag or a way to check for overflow when assigning some variable.

ubyte u = 260; // Here should be given some warning or throw exception.

It's ubyte, but it could be any other data type.

Thanks anyway,


Reply via email to