I need a condition in my rhodes app to check if a class variable @@abc is initialized then do something else something.
How can i get this done?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Try using defined?
If the variable is defined, you’ll receive back a string with the kind of the variable, otherwise defined? will return nil. beware that defined?(nil) will return the string “nil”, not the value nil.
There’s also a very ruby idiomatic way to do something akin to “if not defined do this”, which is
Quick examples: