提交 ad62b475 编写于 作者: 3 3dgen

增加具名interface例子

上级 d6d7b56d
# 版权 @2021 凹语言 作者。保留所有权利。
type S1 struct {
a: i32
}
type S2 struct {
a: i32
}
type i1 interface {
f()
}
func S1.f() {
println("This is S1, this.a==", this.a)
}
func S2.f(){
println("This is S2, this.a==", this.a)
}
fn main() {
v1 := S1{a: 13}
v2 := S2{a: 42}
var i: i1 = &v1
i.f()
i = &v2
i.f()
}
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册