Define a primitive data type: Difference between revisions

Changed low bound to 1 to conform to the task requirement.
(→‎{{header|J}}: prior version could have been tricked by clever complex number such as 2ad113. Error messages improved.)
(Changed low bound to 1 to conform to the task requirement.)
Line 1,695:
=={{header|Nim}}==
Subranges are supported by the language and automatically boundchecked:
<lang pythonNim>type
MyInt = range[01..10]
 
var x: MyInt = 5
 
x = x + 6 # Runtime error: unhandled exception: value out of range: 11 notin 1 .. 10 [RangeDefect]
 
x = 12 # Compile-time error: conversion from int literal(12) to MyInt is invalid</lang>
 
=={{header|OCaml}}==
Anonymous user