mirror of
https://github.com/unknwon/the-way-to-go_ZH_CN.git
synced 2025-08-12 03:55:28 +08:00
Update interfaces.go
This commit is contained in:
@@ -19,12 +19,12 @@ func main() {
|
|||||||
sq1 := new(Square)
|
sq1 := new(Square)
|
||||||
sq1.side = 5
|
sq1.side = 5
|
||||||
|
|
||||||
// var areaIntf Shaper
|
var areaIntf Shaper
|
||||||
// areaIntf = sq1
|
areaIntf = sq1
|
||||||
// shorter, without separate declaration:
|
// shorter, without separate declaration:
|
||||||
// areaIntf := Shaper(sq1)
|
// areaIntf := Shaper(sq1)
|
||||||
// or even:
|
// or even:
|
||||||
areaIntf := sq1
|
// areaIntf := sq1
|
||||||
fmt.Printf("The square has area: %f\n", areaIntf.Area())
|
fmt.Printf("The square has area: %f\n", areaIntf.Area())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user