Skip to content

Latest commit

 

History

History
43 lines (29 loc) · 581 Bytes

File metadata and controls

43 lines (29 loc) · 581 Bytes

Names Return Values

Objectives

  1. What is the result of the following code?
package main
        
import "fmt"
        
func add(x, y int) {
    var z int = x + y                     
    return z
}
       
func main() {
    fmt.Print(add(3, 2))
}
  1. Fix the code above

  2. Will the following code work properly? Explain

package main
        
import "fmt"
        
func add(x, y int) (z int) {
    z = x + y                     
    return
}
       
func main() {
    fmt.Print(add(3, 2))
}

Solution

Click here to view the solution