Last active
February 6, 2019 09:03
-
-
Save chardos/1b63ec6aae1830a80907d347a3c1125e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import "fmt" | |
type Rect struct { | |
width int | |
height int | |
} | |
func (r *Rect) PrintArea() string { | |
area := fmt.Sprintf("Area: %d", (r.width * r.height)) | |
return area | |
} | |
func main() { | |
rect := Rect{10, 20} | |
fmt.Println(rect) | |
fmt.Println(rect.width) | |
fmt.Println(rect.PrintArea()) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment