From: Martin DeMello Date: 2012-05-18T12:07:39+09:00 Subject: Re: what is going wrong here? The case of the noob not understanding initialize On Thu, May 17, 2012 at 6:38 PM, roob noob wrote: >  def contains_dictionary_word?(password) >  entropy_bits = 0 >  passed_dictionary_test = true >  File.open("#{RELATIVEPATH}/data/dictionary") do |dictionary| >    while line = dictionary.gets >      passed_dictionary_test = false and break if > password.include?(line.chop) >    end >    entropy_bits = 6 if passed_dictionary_test and password.length > 4 >    end >    return entropy_bits >  end Two notes: 1. By common ruby convention, methods ending with a ? return a boolean, not an int 2. This does not do what you think it does: passed_dictionary_test = false and break if password.include?(line.chop) it parses as (passed_dictionary_test = false) and (break if password.include?(line.chop)) then (passed_dictionary_test = false) is an expression, which returns its rhs, which is false, so the bit after the "and" is never evaluated. The following code is illustrative - guess what it does, then run it and see: x = 0 passed = true while x < 10 passed = false and break if x == 5 puts "x = #{x}, passed = #{passed}" x += 1 end This form of your original code works: if password.include?(line.chop) passed_dictionary_test = false break end martin