Abstract type: Difference between revisions
Content added Content deleted
Line 1,105: | Line 1,105: | ||
A variable of an interface type can hold a value of any type that implements the methods that are specified in the interface. You don't need to explicitly "declare" that the type "implements" the interface or anything like that -- the compatibility is purely structural based on the methods. |
A variable of an interface type can hold a value of any type that implements the methods that are specified in the interface. You don't need to explicitly "declare" that the type "implements" the interface or anything like that -- the compatibility is purely structural based on the methods. |
||
<lang go>package main |
::<lang go>package main |
||
import "fmt" |
import "fmt" |