Code Tunning


#1

Hi!
there is a better way to do that?

if anArray.include?(id)
state=‘YES’
else
state=‘NOT’
end

puts “#{id}: #{state} included”

Thanks!


#2

Farrel L. wrote:

state = anArray.include?(id) ? ‘YES’ : ‘NO’

Oh! Im an idiot!
Thanks a lot!!!


#3

2008/12/2 Fernando G. removed_email_address@domain.invalid:

if anArray.include?(id)
state=‘YES’
else
state=‘NOT’
end

state = if anArray.include?(id)
‘YES’
else
‘NO’
end

or

state = anArray.include?(id) ? ‘YES’ : ‘NO’

Farrel

Aimred - Ruby Development and Consulting
http://www.aimred.com