From: Andrew Wagner Date: 2010-10-13T22:46:27+09:00 Subject: Re: Options in a class --000325556c027bbae204927fcff0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Try this: module Abc def self.test(arg =3D> :red) puts arg end end puts Abc.test # =3D> red puts Abc.test(:blue) #=3D> blue On Wed, Oct 13, 2010 at 9:41 AM, Paul Bergstrom wrote= : > I have some problems understanding the basics of classes and modules in > Ruby =E2=80=93 and arg and options. How do you create a e g class that ca= n take > some options, but leave them out if not needed? This is what I'm > familiar with now, sending along an arg to the method in a module. > > module Abc > def self.test(arg) > puts arg > end > end > > > In this occasion I have to pass along a an arg, or nil, or there will an > error. But how do I design my module so I can pass options, or leave > them out if wanted? Like: > > Abc.test(:color =3D> 'red') or Abc.test() > > -- > Posted via http://www.ruby-forum.com/. > --000325556c027bbae204927fcff0--