Created
November 2, 2017 01:28
-
-
Save carld/502e0527ac7211b1d81d80fd4ab68714 to your computer and use it in GitHub Desktop.
break out of reduce
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
run = ->(a,v) { a.reduce(v){|x,y| break unless y.call(v); x } } | |
run.call [ | |
->(v) { puts "Hello"; true }, | |
->(v) { puts "World"; false }, | |
->(v) { puts "!"; true } | |
], 1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment