When I’m not worried about performance, I’ll often use this:
if my_string.to_s == ''
# It's nil or empty
end
There are various variations, of course…
if my_string.to_s.strip.length == 0
# It's nil, empty, or just whitespace
end
When I’m not worried about performance, I’ll often use this:
if my_string.to_s == ''
# It's nil or empty
end
There are various variations, of course…
if my_string.to_s.strip.length == 0
# It's nil, empty, or just whitespace
end