How do you check whether a variable is defined in Ruby? Is there an "isset"-type method available?
|
Use the
As skalee commented: "It is worth noting that variable which is set to nil is initialized."
|
||||
this is useful if you want to do nothing if it does exist but create it if it doesn't exist
this only creates the new class once after that just keeps returning the var |
|||||||||||||||||
|
The correct syntax for the above statement is:
substituting ( |
||||
|
|||
|
Try "unless" instead of "if"
|
|||||||
|
Here is some code, nothing rocket science but it works well enough
|
|||||||||||
|
You can try:
Because it returns a boolean. |
|||||
|