Mailinglist Archive: yast-devel (246 mails)

< Previous Next >
Re: [yast-devel] Re: [yast-commit] <web-client> master : use lambdas instead loops
  • From: Josef Reidinger <jreidinger@xxxxxxx>
  • Date: Tue, 04 Aug 2009 10:09:01 +0200
  • Message-id: <4A77EC9D.4010101@xxxxxxx>
On 08/04/2009 10:07 AM, Klaus Kaempf wrote:
* Josef Reidinger <jreidinger@xxxxxxx> [Aug 04. 2009 10:00]:

+ region = timezones.find { |reg| reg.name == params[:region] }
+ region = {} unless region

This can be further shortened by writing

region = (timezones.find { |reg| reg.name == params[:region] }) || {}

Where I prefer

region = (timezones.find { |reg| reg.name == params[:region] }) || Hash.new

to make it less cryptic ;-)


Thanks, you are right...and exist some trick to get return value of find
and if nil then call another function like a.find() ?? .id so result
will be id or nil?
Josef

--
Josef Reidinger
YaST team
maintainer of perl-Bootloader, YaST2-Repair, webyast modules language
and time
--
To unsubscribe, e-mail: yast-devel+unsubscribe@xxxxxxxxxxxx
For additional commands, e-mail: yast-devel+help@xxxxxxxxxxxx

< Previous Next >
Follow Ups
References