有Array類我如何訪問數組的屬性在Ruby中
>> answers_to_problem
=> [#<Answer id: 807, problem_id: 1, player_id: 53, code: "function y = times2(x
)\r\n y = 2*x;\r\nend", message: nil, score: 12, output: nil, hide: nil, create
d_at: "2010-02-02 11:06:49", updated_at: "2010-02-02 11:06:49", correct_answer:
nil, leader: nil, success: true, cloned_from: nil>]
的這個對象做一個二進制的檢查,我需要訪問成功場。我不知道我甚至在這裏使用正確的術語,所以我不能搜索如何訪問它。
answer_to_problems發現這樣:
answers_to_problem = Answer.find_all_by_problem_id_and_player_id(current_problem,player_id)
最後,我想這樣做的檢查:
is_correct = (answers_to_problem.success == true)
它是對象的數組,即使它是一個「標」。所以,這就是小規模啓蒙的感覺! – MatlabDoug 2010-02-02 18:33:27