Created
October 5, 2022 20:28
-
-
Save hemalvarambhia/a7dada1cbefa9050ddd5d9a0dd357634 to your computer and use it in GitHub Desktop.
An Example of a Collection Object
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
class Employees | |
include Enumerable | |
def initialize(employees) | |
@employees = employees | |
end | |
def each &block | |
@employees.each &block | |
end | |
end | |
x = Employees.new([ OpenStruct.new(name: 'Anna'), OpenStruct.new(name: 'Ekta')]) | |
x.select { |employee| employee.name == 'Anna' } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment