Mailinglist Archive: yast-devel (246 mails)

< Previous Next >
[yast-devel] Re: [yast-commit] <web-client> master : use lambdas instead loops
  • From: Klaus Kaempf <kkaempf@xxxxxxx>
  • Date: Tue, 4 Aug 2009 10:07:41 +0200
  • Message-id: <20090804080741.GA15209@xxxxxxxxxxxxx>
* 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 ;-)


Klaus
---
SUSE LINUX Products GmbH, GF: Markus Rex, HRB 16746 (AG N├╝rnberg)

--
To unsubscribe, e-mail: yast-devel+unsubscribe@xxxxxxxxxxxx
For additional commands, e-mail: yast-devel+help@xxxxxxxxxxxx

< Previous Next >