【发布时间】:2011-05-21 19:33:31
【问题描述】:
这是代码:
xml = REXML::Document.new(data)
@contacts = Array.new
xml.elements.each('//entry') do |entry|
person = {}
person['name'] = entry.elements['title'].text
gd_email = entry.elements['gd:email']
person['email'] = gd_email.attributes['address'] if gd_email
@contacts << person
end
@contacts.sort_by { |k| k['name'] } if @contacts[0].size > 0
错误:
You have a nil object when you didn't expect it!
You might have expected an instance of Array.
The error occurred while evaluating nil.<=>
【问题讨论】:
标签: ruby sorting enumerable