Why do I have to cast arguments from int to byte?
kdevel
kdevel at vogtner.de
Fri Oct 13 09:52:59 UTC 2017
On Friday, 13 October 2017 at 07:47:55 UTC, Daniel Kozak wrote:
> but it works ok with immutable, so until you really need to
> change bar you can use
>
> immutable bar = 9;
> foo!byte(bar + 1);
As Adam wrote two days ago: 'D doesn't do implicit narrowing
conversion... so x + 1 becomes int, but then int to byte requires
an explicit cast (unless the compiler can prove the range in that
particular expression - this is called "value range
propagation").'
More information about the Digitalmars-d-learn
mailing list