From: Tim Pease Date: 2009-02-13T07:43:59+09:00 Subject: Re: Better way to do this? On Feb 12, 2009, at 3:24 PM, Pito Salas wrote: > Hi, > > I seem to be repeating myself in the following little bit: > > if (!@options[:namespace].nil?) > namespace_options = @options[:namespace] > root.add_namespace(namespace_options[:namespace], > namespace_options[:value]) > end > > Can someone show me a way to not repeat options[:namespace] ? > > Simpler example of the exact same: > > if (!hash[:value].nil?) > h = hash[:value] > puts h[:left], h[:right] > end > if (h = hash[:value]) puts h[:left], h[:right] end Blessings, TwP