From: burke Date: 2010-01-26T13:10:13+09:00 Subject: Re: how to refactor these code? A little more context would be helpful, but you could do something like: def ss(options={}) s = options.delete(:s) || "hello" yeah = options.delete(:yeah) puts (yeah ? "something" : "other thing") #code continue .... end ss(:hello => 'hi', :yeah => true) ss(:yeah => false) and so on. Burke Libbey On Jan 25, 8:53 pm, Zhenning Guan wrote: > def ss(s = 'hello', yeah = nil) >   if yeah >     puts "something" >   else >     puts "other thing" >   end > >   #code continue .... > end > > I have this method, use it like that: > > ss('hi', yeah = true) > ss('hello') > ss('fuck', yeah = true) > ss('hello',yeah = true) > > very ugly.. sometimes I just need to passed yeah = true, but I have to > added 'hello' first. > > what should I do? > -- > Posted viahttp://www.ruby-forum.com/.