From: Tom Stut Date: 2013-02-08T15:48:05+09:00 Subject: #split vs. #length. Different returns. I am wondering why these two lines of code at the bottom, which seem to say the same thing, produce different results. text is simply a long string. words = text.scan(/\w+/) stop_words = %w{the a by on for of are with just but and to the my I has some in} key_words = text.split{/\w../}.select{|word| !stop_words.include?(word)} # This line of code results in a higher percentrage of key words to stop words 76.58% key_words_to_stop_words = ((key_words.length.to_f / text.split{/\w../}.count.to_f) * 100) # This line has been rendered as a comment, but produces 75.13% when run through ruby # key_words_to_stop_words = ((key_words.length.to_f/ words.length.to_f) * 100) puts "#{key_words_to_stop_words} % of key words." -- Posted via http://www.ruby-forum.com/.