Hacker News new | ask | show | jobs
by sacado2 3885 days ago

    type Optional struct {
        stuff interface{}
        present bool
    }
    
    func (o Optional) Get() (interface{}, bool) {
        return o.stuff, o.present
    }

    func NewOptional(stuff interface{}) {
        return Optional(stuff, true)
    }