def my_method(arr)
  arr.each do |element|
    puts element
  end
end


data = nil
my_method(data)

--output:--
Line 2:in `my_method': undefined method `each' for nil:NilClass 
(NoMethodError)
  from t.rb:9

-- 
Posted via http://www.ruby-forum.com/.