Jump to content

Define a primitive data type: Difference between revisions

Add Nimrod
(→‎{{header|ooRexx}}: corrected to take care of a*2)
(Add Nimrod)
Line 872:
<lang modula3>TYPE MyInt = [1..10];</lang>
<code>MyInt</code> can now be used anywhere an <code>INTEGER</code> can, such as the standard arithmetic functions. Trying to assign a value outside of the range of <code>MyInt</code> will result in a compile time warning, and/or a runtime error.
 
=={{header|Nimrod}}==
Subranges are supported by the language and automatically boundchecked:
<lang nimrod>var x: range[1..10] = 10
 
x = 5
 
x = x + 6 # Runtime error: Value out of range
 
x = 12 # Compile error: Invalid conversion</lang>
 
=={{header|OCaml}}==
Anonymous user
Cookies help us deliver our services. By using our services, you agree to our use of cookies.