Mailinglist Archive: yast-devel (246 mails)

< Previous Next >
Re: [yast-devel] Re: [yast-commit] <web-client> master : use lambdas instead loops
  • From: Klaus Kaempf <kkaempf@xxxxxxx>
  • Date: Tue, 4 Aug 2009 11:12:17 +0200
  • Message-id: <20090804091217.GE20111@xxxxxxxxxxxxx>
* Josef Reidinger <jreidinger@xxxxxxx> [Aug 04. 2009 10:15]:
On 08/04/2009 10:07 AM, Klaus Kaempf wrote:

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?

Look at Enumerable#detect (find is an alias to detect)
(http://ruby-doc.org/core/classes/Enumerable.html#M003123).

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 >