So I generate an array containing CSV::Row
objects and nil as follows in Ruby 1.9.3-p374:
csv_array = [nil, #<CSV::Row "name":John>, nil, nil, #<CSV::Row "name":John>]
The following line of code works fine:
csv_array.delete_if { |x| x.nil? }
But this line gives an error:
csv_array.delete_if { |x| x==nil }
Error:
.rvm/rubies/ruby-1.9.3-p374/lib/ruby/1.9.1/csv.rb:478:in `==': undefined method `row' for nil:NilClass (NoMethodError)
Any ideas on why this might be? I thought ==nil
and .nil?
would yield the same result.