Created
March 6, 2013 19:14
-
-
Save rsutphin/5102133 to your computer and use it in GitHub Desktop.
Surprising each_with_object behavior
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 1.9.3p194 :001 > %w(a b c).each_with_object(['foo']) { nil } | |
| => ["foo"] | |
| 1.9.3p194 :002 > %w(a b c).each_with_object(['foo']) { break } | |
| => nil |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
In case anybody like me is looking for a solution to break and still return the object mid-iteration. This works: