Created
August 27, 2014 18:51
-
-
Save Yardboy/05bb7f5044d7db2bbf5a to your computer and use it in GitHub Desktop.
Ruby any? and all? with an empty array as receiver.
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
2.0.0-p451 :001 > [].any? { |wtf| wtf.locked? } | |
=> false | |
2.0.0-p451 :002 > [].all? { |wtf| wtf.locked? } | |
=> true |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Enumerable#any?
"Does at least one element of the collection fulfill the condition?"Enumerable#all?
"Do all the elements of the array fulfill the condition?"With an empty collection, zero elements fulfill the condition. Which isn't at least one, but is all of them.