How to check if a variable is defined in Ruby?

Posted by Rohit Kumar | Updated on

Want to check if a variable is defined in Ruby? Use the defined? keyword (documentation). It will return a String with the kind of the item, or nil if it doesn’t exist.


If you like this question & answer and want to contribute, then write your question & answer and email to freewebmentor[@]gmail.com. Your question and answer will appear on FreeWebMentor.com and help other developers.

Related Questions & Answers