do .. unless

J

Josselin

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?
 
K

Kevin Jackson

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
 
R

Robert Klemme

how about:

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

Maybe this (untested):

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

Kind regards

robert
 
D

Devin Mullins

Josselin said:
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
 
A

atbusbook

Devin said:
Josselin said:
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,212
Messages
2,571,102
Members
47,698
Latest member
TerraT521

Latest Threads

Top