Mega Code Archive

 
Categories / Ruby / Class
 

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")