我搜索了很多,但我现在很难过。我希望简化一个数组,这样使用起来会更容易一些......
现在我的数组看起来像这样:
[[{"title"=>"Test Entry 2", "date"=>"2013-11-01 21:05"}, "\nThis is just another test entry."], [{"title"=>"Test Entry", "date"=>"2013-11-01 18:05"}, "\nThis is just a test entry."]]
并打印我目前拥有的这些值:
entries.each do |x|
puts x[0]["title"]
puts x[0]["date"]
puts x[1]
end
我希望它看起来像这样(我认为):
[{"title"=>"Test Entry 2", "date"=>"2013-11-01 21:05", "content"=>"\nThis is just another test entry".}], [{"title"=>"Test Entry", "date"=>"2013-11-01 18:05", "content"="\nThis is just a test entry.}]
我希望能够通过循环轻松调用这些值,例如:
entries.each do |entry|
puts entry["title"]
puts entry["date"]
puts entry["content"]
end
任何帮助,将不胜感激。谢谢看!!