Oops sorry wrong button
I am apologize, I wrote my question in French
My problem is why i did something like
************************
Assuming:
rtCriteria = ""
array = {:bolo => "toto" , :bolo => "toto" }
Actually array is a hash and it has only one pair of values :bolo => "toto"
array.each {|key,value| rtCriteria = "#{key} = '#{value}'" }
You will habe rtCriteria ="bolo = 'toto'" and not blank?, but blank?
is not Ruby, I believe it is defined somewere in the Rails libraries.
In Ruby you can use rtCriteria.strip.empty? I believe.
if rtCriteria.blank?
As I said above rtCriteria is not blank it's value = "bolo = 'toto'"
puts "rtCriteria is ok"
else
puts "rtCriteria is not "ok
end
**************
I have always
rtCriteria is not ok
the if method was called before the each method
It was not, if it were rtCretieria might be blank indeed!
It's more clear ?
Yes and now, I know what is wrong in your code but I do not know what you want.
You probably want a string like this
"bolo => 'toto', robert => 'titi'" for a hash.
In that case try this
result =""
{:bolo => 'toto', :robert => 'titi'}.each{|k,v| result<< ", #{k} = '#{v}'"}
result[2..-1]
The *Ruby* way might be to use inject though
{:bolo => 'toto', :robert => 'titi'}.inject(){|a,(k,v)| a << "#{k} =
'#{v}'"}.join(", ")
If it is something else you want to achieve just tell us what the
exact result should be.
Cheers
Robert
···
On 5/4/07, Bolo <malavoi@gmail.com> wrote:
--
You see things; and you say Why?
But I dream things that never were; and I say Why not?
-- George Bernard Shaw