From: "Jesús Gabriel y Galán" Date: 2010-10-13T23:04:10+09:00 Subject: Re: Options in a class On Wed, Oct 13, 2010 at 3:46 PM, Andrew Wagner wrote: > Try this: > module Abc >  def self.test(arg => :red) >    puts arg >  end > end > > puts Abc.test # => red > puts Abc.test(:blue) #=> blue The above should be '=', not '=>'. Like this: irb(main):010:0> module Abc irb(main):011:1> def self.test(color = :red) irb(main):012:2> puts color irb(main):013:2> end irb(main):014:1> end => nil irb(main):015:0> Abc.test red => nil irb(main):016:0> Abc.test(:blue) blue => nil As you mentioned "options", it seems that you might want to allow passing several options, not just one argument. The usual idiom for that is using a hash: irb(main):017:0> module Abc irb(main):018:1> def self.test(options = {}) irb(main):019:2> color = options[:color] || :red irb(main):020:2> size = options[:size] || 3 irb(main):021:2> puts color,size irb(main):022:2> end irb(main):023:1> end => nil irb(main):024:0> Abc.test red 3 => nil irb(main):025:0> Abc.test(:color => :blue) blue 3 => nil irb(main):027:0> Abc.test(:color => :blue, :size => 5) blue 5 => nil You could also have the default values in the default argument: def self.test(options = {:color => :red, :size => 3}) or like this: def self.test(options = {}) options = {:color => :red, :size => 3}.merge(options) end Jesus.