K
kovax
Hello,
I have an array filled with employee objects that are defined like
this:
Employee = Struct.newname, :age)
I would like to use the find_all method on an array of employee objects
to find all employee objects with an age > 18. I tried the following
code but I was unsuccessful:
employees = []
employees.add Employee.new("joe" , 4)
employees.add Employee.new("sam" , 20)
employees.select { Employee.age > 18 }
Any help or pushes in the right direction would be really appreciated.
I have an array filled with employee objects that are defined like
this:
Employee = Struct.newname, :age)
I would like to use the find_all method on an array of employee objects
to find all employee objects with an age > 18. I tried the following
code but I was unsuccessful:
employees = []
employees.add Employee.new("joe" , 4)
employees.add Employee.new("sam" , 20)
employees.select { Employee.age > 18 }
Any help or pushes in the right direction would be really appreciated.