❔ Polymorphism
Can someone help me understand this part of the code? I dont understand why its being written like this...
10 Replies
E.g., why do we have to use property function if field is set to public?
You only have one field here, and its private.
you have one property, and its public
isnt these the fields
and this the property?
private List<Account> _accounts;
is a field
oh my bad! i just realized
is a constructor
can I ask, why dont the account field go into the constructor's args?
It could! Depends on how you want it to work.
In this case, it always creates a new, empty list when a branch is constructed.
you could do that, but this class is assumed to own the state, so giving it a mutable list could lead to unexpected things
Was this issue resolved? If so, run
/close
- otherwise I will mark this as stale and this post will be archived until there is new activity.