Issue #16096 has been updated by shevegen (Robert A. Heiler).


In ruby it is in general very rare that deeply nested (and multiple) .each
are necessary.

I recommend to you to use "pp" before you run the loop, such as:

    pp obj

Perhaps you have an empty Array there - that happens to me sometimes 
where I would otherwise get confused why .each is not running.

This is also why I love pp. :)

As Jeremy wrote, it is very likely to assume that something is
not quite right with .each for the object; or it is empty.

----------------------------------------
Misc #16096: each in each (multiple uses 'each')
https://bugs.ruby-lang.org/issues/16096#change-80573

* Author: D1mon (Dim F)
* Status: Feedback
* Priority: Normal
* Assignee: 
----------------------------------------
``` ruby
obj.each {|a|
    a.some_method1.each {|b|
        ... # comes here (enter)
    }
    a.some_method2.each {|c|
        ... # does not enter here
    }
}

# tried and that way. also does not go
for a in obj
    for b in a.some_method1
        ... # comes here
    end
    for c in a.some_method2
        ... # does not enter here
    end
end
```

help solve the problem. I”Ēve been suffering for 2 days.




-- 
https://bugs.ruby-lang.org/

Unsubscribe: <mailto:ruby-core-request / ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>