| 1. |
What do you understand by each of the functions demo_func() as shown in the below code? |
|
Answer» //DemoStruct definitiontype DemoStruct struct { Val int}//A.func demo_func() DemoStruct { return DemoStruct{Val: 1}}//B.func demo_func() *DemoStruct { return &DemoStruct{}}//C.func demo_func(s *DemoStruct) { s.Val = 1} A. Since the function has a return type of the struct, the function RETURNS a copy of the struct by setting the value as 1. |
|