How to check that variable is defined

There are minimu two ways. First - by using defined? method:

 if defined? my_var puts "exists" else puts "doesn't exist" end 

defined? method returns type of variable if variable exists and nil otherwise. Second way is by initializing variable which you want to check ...

It cost nothing - so that way it looks like that:
 my_var = nil if my_var.nil? #logic goes here else #otherwise end 



Makailah wrote

One or two to reembmer, that is.


Great stuff, you hpleed me out so much!