![]() |
VOOZH | about |
In Go structure, the working of promoted methods is just like Promoted Fields. We use this concept in the nested structure where a structure is a field in another structure, simply by just adding the name of the structure into another structure and it behaves like the Anonymous Field to the nested structure. And the methods of that structure (other than nested structure) are the part of the nested structure, such type of methods are known as Promoted Methods. Or in other words, prompted methods are those methods which are implemented by the child structure, and is accessible by the parent structure.
Important Points:
Example 1:
Output:
Name: Sumit
Age: 28
Gender: Male
Per day salary: 890
Total Salary: 26700
Post: HR
Employee id: 4567
Example 2:
Output:
Name: Sumit
Age: 28
Gender: Male
Per day salary: 890
Total Salary: 150
Post: HR
Employee id: 4567
Total Articles: 150