Anonymous user
Undefined values: Difference between revisions
added ruby partially
(remove distinction from NULL.) |
(added ruby partially) |
||
Line 129:
<pre>var is undefined at first check
var is undefined at third check
Done
</pre>
=={{header|Ruby}}==
<lang ruby>
# Check to see whether it is defined
puts "var is undefined at first check" unless defined? var
# Give it a value
var = "Chocolate"
# Check to see whether it is defined after we gave it the
# value "Chocolate"
puts "var is undefined at second check" unless defined? var
# I don't know any way of undefining a variable in Ruby
# Because most of the output is conditional, this serves as
# a clear indicator that the program has run to completion.
puts "Done"
</lang>
Results in:
<pre>var is undefined at first check
Done
</pre>
|