8000 Go面向对象编程6——嵌入 interface · Issue #194 · holdyounger/ScopeBlog · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
Go面向对象编程6——嵌入 interface #194
Open
@holdyounger

Description

@holdyounger

Go面向对象编程6——嵌入 interface

在前面的课程中我们已经知道在结构体中可以嵌入匿名字段,其实在接口里也可以再嵌入接口。如果一个 interface1 作为 interface2 的一个嵌入字段,那么 interface2 隐式的包含了 interface1 里的方法。如下例子中,Interface2 包含了 Interface1 的所有方法。

type Interface1 interface {
    Send()
    Receive()
}

type Interface2 interface {
    Interface1
    Close()
}

blog link Go面向对象编程6——嵌入 interface

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0