From: Robert Klemme Date: 2010-12-14T17:33:09+09:00 Subject: Re: String or string On Tue, Dec 14, 2010 at 3:03 AM, Sam Duncan wrote: > ruby-1.9.2-p0 > u2 = "foo" >  => "foo" > ruby-1.9.2-p0 > puts "blah" unless ["force", "spells"].include?(u2) > blah >  => nil > ruby-1.9.2-p0 > u2 = "force" >  => "force" > ruby-1.9.2-p0 > puts "blah" unless ["force", "spells"].include?(u2) >  => nil > ruby-1.9.2-p0 > u2 = "spells" >  => "spells" > ruby-1.9.2-p0 > puts "blah" unless ["force", "spells"].include?(u2) >  => 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 == "force" || s == "spells" irb(main):005:1> puts 'blah3' unless /\A(?:force|spells)\z/ =~ s irb(main):006:1> end Testing "foo" blah1 blah2 blah3 Testing "force" Testing "spells" => ["foo", "force", "spells"] irb(main):007:0> Kind regards robert -- remember.guy do |as, often| as.you_can - without end http://blog.rubybestpractices.com/