If the primary use for reports is to extract by id, then consider using a hash instead:
reports = {} reports[1] = OReport.new(1, 'One', 'One Desc') reports[2] = OReport.new(2, 'Two', 'Two Desc') reports[3] = OReport.new(3, 'Three', 'Three Desc') p reports[2].name
Searching for hashes is usually faster than searching in an array, but more importantly, easier.
source share