Reputation: 55
My problem is:
"1".empty? == false
But:
1.empty? == NoMethodError: undefined method `empty?' for 1:Fixnum
If I change it to blank?
"1".blank? == false
1.blank? == false
So, I want to know the other way to check an integer is empty or not because I hate blank?
Upvotes: 2
Views: 4885
Reputation: 7941
Here are some examples about nil? and empty?
nil.nil?
# => true
false.nil?
# => false
1.nil?
# => false
0.nil?
# => false
"".nil?
# => false
[].nil?
# => false
"".empty?
# => true
"abc".empty?
# => false
[].empty?
# => true
[1, 2, 3].empty?
=> false
1.empty?
=> NoMethodError
The last example means that the empty?
method is not defined for class
Fixnum
Upvotes: 4