我有一個看起來像這樣的數組。Ruby訪問數組元素
[{"EntryId"=>"2", "Field1"=>"National Life Group","DateCreated"=>"2010-07-30 11:00:14", "CreatedBy"=>"tristanoneil"},
{"EntryId"=>"3", "Field1"=>"Barton Golf Club", "DateCreated"=>"2010-07-30 11:11:20", "CreatedBy"=>"public"},
{"EntryId"=>"4", "Field1"=>"PP&D Brochure Distribution", "DateCreated"=>"2010-07-30 11:11:20", "CreatedBy"=>"public"},
{"EntryId"=>"5", "Field1"=>"Prime Renovation Group, DreamMaker Bath & Kitchen", "DateCreated"=>"2010-07-30 11:11:21", "CreatedBy"=>"public"}
]
我怎麼會去通過這個循環訪問數組,所以我可以指定我想打印出來,並得到其價值領域,所以我可以做這樣的事情。
puts EntryId.value
這工作出色。 – 2010-10-02 21:06:31
我有一個類似的問題,但是當我使用'entry [「EntryId」]'我不能將String轉換爲Integer(TypeError)'' – 2014-03-25 06:09:49