Assertions in design by contract: Difference between revisions

Added Kotlin
m (→‎{{header|REXX}}: removed an extraneous slash)
(Added Kotlin)
Line 206:
(...)
</lang>
 
=={{header|Kotlin}}==
<lang scala>// version 1.1.2
// requires -ea JVM option
 
fun main(args: Array<String>) {
assert(args.size > 0) { "At least one command line argument must be passed to the program" }
println("The following command line arguments have been passed:")
for (arg in args) println(arg)
}</lang>
 
{{out}}
When run without passing command line arguments:
<pre>
Exception in thread "main" java.lang.AssertionError: At least one command line argument must be passed to the program
</pre>
When run passing 1 and 2 as command line arguments:
<pre>
The following command line arguments have been passed:
1
2
</pre>
 
=={{header|Racket}}==
9,482

edits