#!/usr/local/bin/ruby
class OReport
attr_accessor :id, :name
def initialize(id, name, desc)
@id = id
@name = name
@desc = desc
end
end
reports = Array.new
reports << OReport.new(1, 'One', 'One Desc')
reports << OReport.new(2, 'Two', 'Two Desc')
reports << OReport.new(3, 'Three', 'Three Desc')
我现在如何在“报告”中搜索 2,以便从中提取名称和描述?