ruby-1.9.2-p0 > u2 =3D "foo"
=A0=3D> "foo"
ruby-1.9.2-p0 > puts "blah" unless ["force", "spells"].include?(u2)
blah
=A0=3D> nil
ruby-1.9.2-p0 > u2 =3D "force"
=A0=3D> "force"
ruby-1.9.2-p0 > puts "blah" unless ["force", "spells"].include?(u2)
=A0=3D> nil
ruby-1.9.2-p0 > u2 =3D "spells"
=A0=3D> "spells"
ruby-1.9.2-p0 > puts "blah" unless ["force", "spells"].include?(u2)
=A0=3D> nil
%w can be nicely used here:
Ruby version 1.9.1
irb(main):001:0> %w{foo force spells}.each do |s|
irb(main):002:1* printf "Testing %p\n", s
irb(main):003:1> puts 'blah1' unless %w{force spells}.include? s
irb(main):004:1> puts 'blah2' unless s =3D=3D "force" || s =3D=3D "spells"
irb(main):005:1> puts 'blah3' unless /\A(?:force|spells)\z/ =3D~ s
irb(main):006:1> end
Testing "foo"
blah1
blah2
blah3
Testing "force"
Testing "spells"
=3D> ["foo", "force", "spells"]
irb(main):007:0>
Kind regards
robert
--=20
remember.guy do |as, often| as.you_can - without end
http://blog.rubybestpractices.com/