我有一组 OpenStruct 数据结构。但是当我尝试访问它们时,我只能访问country
array = [
#<OpenStruct country="United States", visits="202", visitBounceRate="59.900990099009896", avgTimeOnSite="151.85148514851485", newVisits="176", percentNewVisits="87.12871287128714", pageviewsPerVisit="2.9207920792079207">,
#<OpenStruct country="Germany", visits="155", visitBounceRate="43.87096774193549", avgTimeOnSite="167.43870967741935", newVisits="104", percentNewVisits="67.0967741935484", pageviewsPerVisit="3.935483870967742">,
#<OpenStruct country="Brazil", visits="105", visitBounceRate="44.761904761904766", avgTimeOnSite="227.2095238095238", newVisits="77", percentNewVisits="73.33333333333333", pageviewsPerVisit="3.5142857142857142">,
#<OpenStruct country="United Kingdom", visits="71", visitBounceRate="46.478873239436616", avgTimeOnSite="216.91549295774647", newVisits="36", percentNewVisits="50.70422535211267", pageviewsPerVisit="3.464788732394366">
]
例如
array.each do |openstruct|
put openstruct.country
end
返回所有国家,但如果我这样做
array.each do |openstruct|
put openstruct.newVisits
end
很多空行被返回。