Last active
March 11, 2020 10:34
-
-
Save whiz25/9549c7397cfad63450308dd87212a53c to your computer and use it in GitHub Desktop.
This file contains 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
- [ ] should be identical and returns the same thing as ruby's [`any?`](https://ruby-doc.org/core-2.6.4/Enumerable.html#method-i-any-3F). ([Screenshot](https://gitlab.com/microverse/guides/projects/requirements_screenshots/raw/master/images/ruby/advanced_building_blocks_enumerable/my_any.png) from [Odin](https://www.theodinproject.com/courses/ruby-programming/lessons/advanced-building-blocks#assignment-2)) | |
- [ ] when no block or argument is given returns true if at least one of the collection is not false or nil | |
```ruby | |
true_array = [nil, false, true, []] | |
true_array.my_any? == true_array.any? #true | |
``` | |
- [ ] when a class is passed as an argument returns true if at least one of the collection is a member of such class | |
```ruby | |
words = %w[dog door rod blade] | |
words.my_any?(Integer) == words.any?(Integer) #true | |
``` | |
- [ ] when a Regex is passed as an argument returns false if none of the collection matches the Regex | |
```ruby | |
words.my_any?(/z/) == words.any?(/z/) #true | |
``` | |
- [ ] when a pattern other than Regex or a Class is given returns false if none of the collection matches the pattern | |
```ruby | |
words.my_any?('cat') == words.any?('cat') #true | |
``` | |
- [ ] returns true if the block ever returns a value other than false or nil | |
```ruby | |
true_block = proc { |num| num <= 9 } | |
false_block = proc { |num| num > 9 } | |
array.my_any?(&true_block) == array.any?(&true_block) #true | |
array.my_any?(&false_block) == array.any?(&false_block) #true | |
``` |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment