2 ms·
Lists allow to express certain constraints in more natural way, like "John has three cats at least one of which is male" or "I want a list of all the people tha
by mrighele 7y ago
Lists allow to express certain constraints in more natural way, like "John has three cats at least one of which is male" or "I want a list of all the people that have at least three friends in common".
You don't have to use lists, but that means code duplication and low maintainability (i.e. instead of stating a condition and "repeating" for all the element of the list, you have to duplicate it explicitly).
It is not so much different from a regular language in this regard: you can write Java without using lists and use a variable for every single element, but who wants to do that ?
- wruza 7y agoI didn’t think about it that way. Nice insight, thank you and all commenters here for your explanations!