Why does Ruby function not break on 'true' in nested loop? -


There is a fragment of Ruby Code which checks that a given email address is part of the 'Receiver' array towards me The email class's property code should be returned back when email_address is found in the list and is not incorrect.

  def is_to_receiver? (Email_address) if @ raw_email.to! = Nil @raw_email To.each do | To_field | | I always thought that the  true  function in line 5 will be broken immediately and the function with the value will be broken. Will return true However, the result of the matching email address was continued from  false  line 11. To make me do this work, changing line 5 was  truth . 

I migrated the code from 1.8.7 to Ruby 1.9.3. And it was worked fine before making sure I'm curious if I have made a mistake or since Ruby 1.9.3 has changed this behavior? Any answer is welcome!

In the absence of the return statement in a ruby, Ruby is executed last The value of the statement will come back. Otherwise, just a lexical statement on them is basically no-ops. If used in the middle of a loop, they will not return because they did not execute the final statement (other statements related to loop processing would have to be executed).

Enter another way, the refund behavior mentioned is only at the very end of a function (a bit bigger, but works for this reference), and you return The keywords must be used anywhere.


Comments

Popular posts from this blog

import - Python ImportError: No module named wmi -

Editing Python Class in Shell and SQLAlchemy -

c# - MySQL Parameterized Select Query joining tables issue -