Hacker News new | ask | show | jobs
by xigoi 320 days ago
> Create the base object, then loop or otherwise control flow over other state to optionally add stuff to the base object.

That’s what list comprehensions are for.

> Then, additionally, the final "build" call can run validations over the set of the complete object.

The constructor function can do that too.

1 comments

The constructor can not do it because the constructor does not have all the data. This is lazy evaluation.