Skip to content

Instantly share code, notes, and snippets.

@whiz25
Last active May 11, 2020 09:02
Show Gist options
  • Save whiz25/1850534c46e9c16d0687b03f21e241c7 to your computer and use it in GitHub Desktop.
Save whiz25/1850534c46e9c16d0687b03f21e241c7 to your computer and use it in GitHub Desktop.
- [ ] should be identical and returns the same thing as ruby's [`select`](https://ruby-doc.org/core-2.6.4/Enumerable.html#method-i-select). ([Screenshot](https://gitlab.com/microverse/guides/projects/requirements_screenshots/raw/master/images/ruby/advanced_building_blocks_enumerable/my_select.png) from [Odin](https://www.theodinproject.com/courses/ruby-programming/lessons/advanced-building-blocks#assignment-2))
- [ ] returns an enumerator if no block is given
```ruby
array = Array.new(100){rand(0...9)}
array.my_select == Enumerator #true
```
- [ ] returns an array containing all elements of enum for which the given block returns a true value
```ruby
array = Array.new(100){rand(0...9)}
array.my_select(&block) == array.select(&block)
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment