From: Andrew Walrond Date: 2003-06-12T05:18:02+09:00 Subject: Re: Multiple Initialize methods? You can't overload initialize like that in ruby. Could you do something like def initialize(*args) which would give you an array or args of size args.size or def.initialize(val1=nil,val2=nil) with obvious results Andrew Nick 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. > > >