From: Paul Lutus Date: 2006-11-30T02:28:44+09:00 Subject: Re: Wrong results using named arguments Jason Vogel wrote: > Source: > > [a.rb] > class A > > attr_accessor :id > attr_accessor :name > > def initialize(id = nil, name = nil) > @id = id > @name = name > end > end > > [test.rb] > require 'a' > > a1 = A.new(:name => "test") > a2 = A.new(:name => "test2") As your class is written, you must provide values: a1 = A.new("id","test") Do you want to define a hash with key-value pairs? Do it this way: def initialize(key,value) @hash = {} @hash[key] = value end In a post like this, always say explicitly what you want to accomplish. -- Paul Lutus http://www.arachnoid.com