Do .. unless

is there any better way to write that :

if !params[:qaddress].nil?
         cond_b = EZ::Where::Condition.new :properties do
    ...
         end
  end

using a do.. unless ? something like that ??

         cond_b = EZ::Where::Condition.new :properties do
    ...
         end unless params[:qaddress].nil?

how about:

unless params[:qaddress].nil?
  cond_b = EZ::Where::Condition.new :properties do
    ...
  end
end

Yeah it only gets rid of the if!, but I think it's more readable

Kev

Josselin wrote:

is there any better way to write that :

if !params[:qaddress].nil?
        cond_b = EZ::Where::Condition.new :properties do
        ...
        end
end

using a do.. unless ? something like that ??

        cond_b = EZ::Where::Condition.new :properties do
        ...
        end unless params[:qaddress].nil?

Well, the unless modifier works here -- if qaddress is nil, cond_b is set to nil. Here's another way:
   cond_b = if params[:qaddress]
     EZ::Where::Condition.new :properties do
        ...
     end
   end

Fnord

Maybe this (untested):

params[:qaddress] and
   cond_b = EZ::Where::Condition.new :properties do
    ...
   end

Kind regards

  robert

···

On 18.09.2006 12:11, Kevin Jackson wrote:

how about:

unless params[:qaddress].nil?
cond_b = EZ::Where::Condition.new :properties do
   ...
end
end

Devin Mullins wrote:

Josselin wrote:
>
> is there any better way to write that :
>
> if !params[:qaddress].nil?
> cond_b = EZ::Where::Condition.new :properties do
> ...
> end
> end
>
> using a do.. unless ? something like that ??
>
> cond_b = EZ::Where::Condition.new :properties do
> ...
> end unless params[:qaddress].nil?
Well, the unless modifier works here -- if qaddress is nil, cond_b is
set to nil. Here's another way:
   cond_b = if params[:qaddress]
     EZ::Where::Condition.new :properties do
        ...
     end
   end

Fnord

<code>
begin
  # do stuff
end while false
</code>
will be done once

> how about:
>
> unless params[:qaddress].nil?
> cond_b = EZ::Where::Condition.new :properties do
> ...
> end
> end

Maybe this (untested):

params[:qaddress] and

Would work if nil were the only thing evaluating to false, but there are
certain instances of the FalseClass, you know :wink:

   cond_b = EZ::Where::Condition.new :properties do

    ...
   end

Kind regards

        robert

           idem

···

On 9/18/06, Robert Klemme <shortcutter@googlemail.com> wrote:

On 18.09.2006 12:11, Kevin Jackson wrote:

--
Deux choses sont infinies : l'univers et la bêtise humaine ; en ce qui
concerne l'univers, je n'en ai pas acquis la certitude absolue.

- Albert Einstein