From: Matthew Moss Date: 2009-01-09T06:55:56+09:00 Subject: Re: code factoring problem > > if @button_next.connect(SEL_COMMAND)==true or > @button_next.connect(SEL_KEYPRESS)==true do There is no need to compare equal to true. Just do this: if @button_next.connect(SEL_COMMAND) or @button_next.connect(SEL_KEYPRESS) do Of course, this is not the same if your connect method can return values other than `true` that are non-false/non-nil. However, if that is the case, it would be wise to reconsider the connect method to do the expected. Alternatively, if this list could grow larger, you might consider something like this: def a_method sels = [SEL_COMMAND, SEL_KEYPRESS] if sels.any? { |sel| @button_next.connect(sel) } do # many lines for handling event A ... ... # end end Just extend `sels` to include the appropriate events/signals.