Created
January 22, 2023 20:49
-
-
Save reetasingh/19f51d0a9b6f3a3e3e49e770f5959467 to your computer and use it in GitHub Desktop.
This file contains hidden or 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" | |
| "math" | |
| ) | |
| type Circle struct { | |
| r float64 | |
| } | |
| func (c *Circle) area() float64 { | |
| if c == nil { | |
| return 0 | |
| } | |
| return math.Pi * c.r * c.r | |
| } | |
| func main() { | |
| var c *Circle | |
| fmt.Printf("(%v, %T)\n", c, c) | |
| fmt.Println(c.area()) | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment