filmov
tv
Testing for undefined variables in ruby.

Показать описание
How to test for undefined variables in ruby.
If you are coming from PHP this is similar to the isset() function. If you are coming from JavaScript it is similar to if (variable_name === undefined).
The script at the end.
variable_name = ""
if !defined?(variable_name)
puts "not defined"
else
puts "defined"
end
wait = gets
If you are coming from PHP this is similar to the isset() function. If you are coming from JavaScript it is similar to if (variable_name === undefined).
The script at the end.
variable_name = ""
if !defined?(variable_name)
puts "not defined"
else
puts "defined"
end
wait = gets