Subrange type

Steven Schveighoffer schveiguy at gmail.com
Mon Jan 27 20:15:33 UTC 2020


On 1/27/20 3:06 PM, Herbert wrote:
> How can I create a subrange type, for example ushort DiceValue {1 ... 6}?

D doesn't have a "Range" type like this. But you can use ranges of 
different types by typing the literals. Note that D numeric ranges are 
always exclusive at the upper end.

e.g.:

ushort(1) .. ushort(6+1)

-Steve


More information about the Digitalmars-d-learn mailing list