Hacker News new | ask | show | jobs
by doragcoder 4067 days ago
You can use object composition: http://play.golang.org/p/jyS38luYjM

Then make a Draw() method on the single object default to what you expect. The simple inline explanation is:

    type SingleObject struct {
        Cowboy
        Shape
    }
Access is as follows to be unambiguous:

     Woody.Cowboy.Draw() 
     Woody.Shape.Draw()
1 comments

The problem is that you can't differentiate SingleObject from CowboyObject and ShapeObject.

They all are the same interface and can be passed into each other's methods, leading to a logical error.