From: John Johnson Date: 2003-06-12T05:21:20+09:00 Subject: Re: Multiple Initialize methods? Set the parameters to some default value that will let you know if they were passed: class Whatever NOT_GIVEN = -1 def initialize(xdim = NOT_GIVEN, ydim = NOT_GIVEN) if xdim = NOT_GIVEN xdim = foo etc. w = Whatever.new w = Whatever.new(23, 44) Regards, JJ on 6/11/03 3:54 PM, Nick at nick.robinson@f.co.uk wrote: > Hi, > > I need to create a class either with a param in the construction or nothing: > > something = Object.new > > or > > something = Object.new(val1, val2) > > I have created an emtpy initialize() method and one with the two params. If > I try to create the object with nothing (first version) then I get > "ArgumentError: wrong number of arguments(0 for 2)". > > class Something > def initialize() > end > def initialize(xdim, ydim) > @xdim = xdim > @ydim = ydim > end > > I put the empty initialze in when things didnt work, thinking i needed at > least a marker. > > Thanks for any help, > > Nick. > > >