From: Sam Duncan Date: 2012-12-06T13:10:17+09:00 Subject: Re: Having isues with capitalizing words On 12/06/2012 05:02 PM, JD KF wrote: > So, this is a method I have made: > > def title(words) > words.gsub(/(\A|\s)\w/) do |word| > if(word!="and" || word!="an" || word!="the") > word.upcase > else > word.downcase > end > end > end > > I have been trying to solve this for the longest time and I can't figure > it out. > > All I want the method to do is take in a string and capitalize every > word except for "and" and "an" and "the". > > The above will not do it and I really don't understand why. I have > tried a million versions of it as well. > > Can someone help me get in the right direction with this? Does this help? > irb 1.9.3p125 :001 > word = 'and' => "and" 1.9.3p125 :002 > word!="and" || word!="an" || word!="the" => true Sam