I have a list of Objects, each of which has a boolean “selected” property. I want these in a set if the “selected” property is true. Other than a for loop through the objects adding each to the set, is there another way to achieve this?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
For something this simple just write a loop and be done with it.
If this is a pattern you’re going to implement over and over:
(untested so there may be a typo or two)
And the invocation
Implementations of
Selectorknow how to examine objects and decide if they should be kept.