From: Sam Kong Date: 2005-11-02T11:17:08+09:00 Subject: How can I avoid this boring code? Hi! I'm creating a class. I wonder if there's a better way. require 'dbi' class Person attr_accessor :person_id, :last_name, :first_name, :home_phone, :work_phone, :address, :city, :state, :zip def initialize(row=nil) if row.class == DBI::Row then @person_id = row.by_field("person_id") @last_name = row.by_field("last_name") @first_name = row.by_field("first_name") @home_phone = row.by_field("home_phone") @work_phone = row.by_field("work_phone") @address = row.by_field("address") @city = row.by_field("city") @state = row.by_field("state") @zip = row.by_field("zip") end end end The code in initialize method is very boring. How could I make it simpler? Thanks in advance. Sam