From: Paul Bergstrom Date: 2010-10-13T23:26:58+09:00 Subject: Re: Options in a class Thomas Sawyer wrote in post #949846: > Simply: > > class Abc > def initialize(opts={}) > @color = opts[:color] > end > end > > But I usually do: > > class Abc > attr_accessor :color > def initialize(opts={}) > opts.each do |k,v| > send("#{k}=", v) > end > end > end > > Also, if you want args and opts, > > def initialize(*args) There it is. Thanks :-) > opts = (Hash === args.last ? args.pop : {}) > ... -- Posted via http://www.ruby-forum.com/.