Code Tunning

Hi!
there is a better way to do that?

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

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

Thanks!

Farrel L. wrote:

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

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

2008/12/2 Fernando G. [email protected]:

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

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs