FAQ
Hi all,

Here's some sample code:

http://play.golang.org/p/XhwtJAT_t0

I am trying to explain to someone why MouseDownEvent2 does not satisfy
the MouseEvent interface, but I am struggling to find the right way to
explain it. Can anyone here help?


Thanks,

Ian

--
You received this message because you are subscribed to the Google Groups "golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.

Search Discussions

  • Tamás Gulácsi at Dec 15, 2013 at 4:34 pm
    MouseEventData is a struct, thus embedding works for it;
    MouseEventData2 is a "virgin" type, thus no methods are defined for it.

    --
    You received this message because you are subscribed to the Google Groups "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].
    For more options, visit https://groups.google.com/groups/opt_out.
  • Jesse McNelis at Dec 15, 2013 at 5:02 pm

    On Mon, Dec 16, 2013 at 3:12 AM, Ian Davis wrote:
    Hi all,

    Here's some sample code:

    http://play.golang.org/p/XhwtJAT_t0

    I am trying to explain to someone why MouseDownEvent2 does not satisfy
    the MouseEvent interface, but I am struggling to find the right way to
    explain it. Can anyone here help?
    The type keyword uses the structure of the given type to create a new
    type, it doesn't care about the types methods.
    So, MouseDownEvent2 has no methods because you never declared any for it.
    http://golang.org/ref/spec#Types

    Embedding creates methods on the embedding type that delegate to
    methods of the embedded field.
    So, MouseDownEvent satisfies MouseEvent because it has the required methods
    http://golang.org/ref/spec#Struct_types


    --
    =====================
    http://jessta.id.au

    --
    You received this message because you are subscribed to the Google Groups "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].
    For more options, visit https://groups.google.com/groups/opt_out.
  • Ian Davis at Dec 15, 2013 at 5:55 pm
    Thanks Jesse and Tamás. I think the key part is that new types have an
    empty



    On Sun, Dec 15, 2013, at 05:02 PM, Jesse McNelis wrote:
    On Mon, Dec 16, 2013 at 3:12 AM, Ian Davis wrote:
    Hi all,

    Here's some sample code:

    http://play.golang.org/p/XhwtJAT_t0

    I am trying to explain to someone why MouseDownEvent2 does not satisfy
    the MouseEvent interface, but I am struggling to find the right way to
    explain it. Can anyone here help?
    The type keyword uses the structure of the given type to create a new
    type, it doesn't care about the types methods.
    So, MouseDownEvent2 has no methods because you never declared any for it.
    http://golang.org/ref/spec#Types

    Embedding creates methods on the embedding type that delegate to
    methods of the embedded field.
    So, MouseDownEvent satisfies MouseEvent because it has the required
    methods
    http://golang.org/ref/spec#Struct_types


    --
    =====================
    http://jessta.id.au
    --
    You received this message because you are subscribed to the Google Groups "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].
    For more options, visit https://groups.google.com/groups/opt_out.

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupgolang-nuts @
categoriesgo
postedDec 15, '13 at 4:12p
activeDec 15, '13 at 5:55p
posts4
users3
websitegolang.org

People

Translate

site design / logo © 2023 Grokbase