Define a primitive data type: Difference between revisions

Line 1,141:
=={{header|Nim}}==
Subranges are supported by the language and automatically boundchecked:
<lang nim>var x: range[1..10] = 10type
MyInt = range[0..10]
 
var x: MyInt = 5
 
x = x + 6 # Runtime error: Valuevalue out of range: 11
 
x = 12 # Compile-time error: Invalid conversion from int literal(12) to MyInt is invalid</lang>
 
=={{header|OCaml}}==
Anonymous user