Does it mean constructor is allowed to change the value of the fields?
I checked it and confirm that it is indeed.
About Question enthuware.ocpjp.v21.2.4038 :
Moderator: admin
-
- Posts: 19
- Joined: Mon Sep 16, 2024 1:49 am
- Contact:
-
- Site Admin
- Posts: 10389
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: About Question enthuware.ocpjp.v21.2.4038 :
No, nobody can change the value of the fields of a record. See this part of the explanation:
So, the constructor is not really changing the value of the fields. It is changing the value of the input parameters.Remember that at the end of the compact record constructor, the compiler adds code that sets all the fields to the values passed in the constructor. So, if the constructor changes the passed value (as is being done in the case of the subjects variable), the updated value will be given to the subjects field of the record instance.
-
- Posts: 19
- Joined: Mon Sep 16, 2024 1:49 am
- Contact:
Re: About Question enthuware.ocpjp.v21.2.4038 :
and it follows that those parameter values are set to fields at the end. seems now I get it. thanks!admin wrote: ↑Sat Jun 14, 2025 9:39 amNo, nobody can change the value of the fields of a record. See this part of the explanation:So, the constructor is not really changing the value of the fields. It is changing the value of the input parameters.Remember that at the end of the compact record constructor, the compiler adds code that sets all the fields to the values passed in the constructor. So, if the constructor changes the passed value (as is being done in the case of the subjects variable), the updated value will be given to the subjects field of the record instance.
Who is online
Users browsing this forum: Bing [Bot] and 3 guests