Comment by 馃尣 greg

=> Re: "Go - can someone explain why empty interfaces can hold any..." | In: s/programming

Interfaces constrain the values they contain to values whose type implements at least the methods specified in the interface.

The empty interface specifies no methods, so a value of any type satisfies it: they all implement at least no methods.

=> 馃尣 greg

2024-11-23 路 8 weeks ago

1 Later Comment

=> 馃崁 gritty [OP] 路 Nov 23 at 22:05:

I guess that makes sense. I first saw this when reading about using an interface as a value in a map for json.

Original Post

=> 馃寬 s/programming

Go - can someone explain why empty interfaces can hold any value, where it seems "regular" interfaces only define functions? In other words, why can the empty interface hold something other than a function definition? new to Go and interfaces in general...

=> 馃挰 gritty 路 2 comments 路 2024-11-23 路 8 weeks ago

Proxy Information
Original URL
gemini://bbs.geminispace.org/u/greg/22116
Status Code
Success (20)
Meta
text/gemini; charset=utf-8
Capsule Response Time
62.601455 milliseconds
Gemini-to-HTML Time
0.442486 milliseconds

This content has been proxied by September (ba2dc).