But I want another method, not the empty?
method, because the empty method can be used only for strings and not integers. What is the correct method?
Well depends really on what you consider an integer empty. There's no such thing as empty?
in the Integer
class because it doesn't make sense. If your variable is of type Integer
or Fixnum
there's no way it is empty somehow: it will always contain a value, a number.
What I guess you are looking for is to test the variable phone
for emptiness in the sense that nil
might be assigned to it. In that case you can simply use:
if name.empty? || phone || adress.empty?
or
if name.empty? || phone.is_a? Fixnum || adress.empty?
if you want to be absolutely sure that phone
is Fixnum
(or any other class for that matter).