Ruby check if string is null or empty
13. March, 2011 Leave a comment
Coming from C# I liked the Frameworks implemented option to check in one go if a given string is null or empty.
Now in Ruby the string class has the method empty? which checks just that i.e. null or empty. But due to the dynamic nature of Ruby one has to tell the interpreter that one would like to have the object as string before you can access the method.
The following code is an example on how it’s done: