From: "Jan E." Date: 2012-05-18T12:39:55+09:00 Subject: Re: what is going wrong here? The case of the noob not understanding initialize Martin DeMello wrote in post #1061234: > > 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)) That's not true (at least not in Ruby 1.9). The "if" modifier has lower precedence then the "and", so the expression is parsed as expected: (passed_dictionary_test = false and break) if ... However, you're right about the "and": Since the left operand is always false, the "break" will never be executed. So you shouldn't read the "and" as "do this and then that". It rather means "do this, and if you were successful, do that". > 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 Have to tested it yourself? If you were right, then "passed" would always be false. But it's only after x has become 5. -- Posted via http://www.ruby-forum.com/.