Hi,
In message "[ruby-talk:24669] Is their a more succinct way to do this?"
on 01/11/09, Jim Freeze <jim / freeze.org> writes:
| 1) they exist
| 2) they are not nil
| 3) they are not empty
|
|So, in my code I have
| if !defined?(param) || param.nil? || param.empty?
| # err
| end
|
|Is there a more compact way to test for this?
In Ruby, local variables are defined statically. This means you can
determine if param is defined or not by looking at the script (if
param is a local variable). So,
if param.nil? || param.empty?
# err
end
is sufficient, I guess. Little bit more compact.
matz.