3 ms·
In go: An interface says this thing is unknown but it has at least these known methods The empty interface means this thing is unknown and its methods are unk
by grey-area 10y ago
In go:
An interface says this thing is unknown but it has at least these known methods
The empty interface means this thing is unknown and its methods are unknown
The first is preferable and the second is not often used.
- bsaul 10y agoThe problem is we need the distinction between "author of the code" unknown ( in which case whatever symbol such as T is enough), and "user of the code" unknown ( in which case relying on dynamic casting or interfaces is fine). What go doesn't provide is 1/ unknown but 2/ not. Which happens when you're creating a lib to be used later.