Creating Objects by Passing Parameters to the New Method : new « Class « Ruby






Creating Objects by Passing Parameters to the New Method


class Customer
@@no_of_customers=0
    def initialize(id, name, addr)
                 @cust_id=id
                 @cust_name=name
                 @cust_addr=addr
    end
end


cust1=Customer.new("0001", "V", "22, road, Atlanta")
cust2=Customer.new("0002", "E", "10, road, Texas")

 








Related examples in the same category

1.Creating Objects the Simple Way