lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


On Thu, Nov 12, 2009 at 12:01 PM, David Given <dg@cowlark.com> wrote:
>      (...) [When using Go] You can't use structs
> as map keys (I don't know about pointers).

The specification page here:

http://golang.org/doc/go_spec.html#Map_types

...says that both pointers and *interfaces* can be used as map key
types. Which I would assume means that a struct can be used as long as
it implements an interface that includes the comparison operators.
This kind of conflicts with the FAQ question that only says that
structs "do not" implement comparison, though:

http://golang.org/doc/go_lang_faq.html#map_keys

...so, it's rather confusing.

-Duncan