We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
interface I { fun f() // var f: ()->unit } class Foo { fun f() { println("") } } class Bar implements I { fun f() } fun useI(i: I) { i.f() } useI( new Foo() ) struct String { fun f() {} } enum Color { fun f() {} }
extension
在原来类型的基础上,添加新的函数。
class Foo { } extension Foo { fun run() { this.xxxx } } /* fun Foo_run(this: Foo) { } */ extension Foo { fun f() {} } fun main() { let x = new Foo() x.run() useI( new Foo() ) } extension Foo implements I { fun f() {} } extension String { fun reverse() -> String { ..... } } "123".reverse()
将一个子字段field的成员(field,method)都委托到当前层级。
class A { let x: Int fun hello() { ...... } fun f() {} } // class B : A {} class B { as let a: A } let b = new B() b.x // b.a.x b.hello() // b.a.hello() b.f() useI( b ) // 如果委托的字段,有重现同名的成员(field,method),这个同名的成员就不会被委托。 class C { fun f() {} } class B { as let a: A as let c: C fun f() { c.f() } } struct D { fun f() {} } struct E { as let d: D }
type A struct { v int } type B struct { A }
The text was updated successfully, but these errors were encountered:
赞成引入这个类型系统设计,不过需要描述文档而不仅仅是不完整的示例
Sorry, something went wrong.
稍晚我写成详细的描述文档,再补充些细节
AllanZyne
thomasyonug
diaozhongpu
No branches or pull requests
非侵入式接口
扩展
extension
在原来类型的基础上,添加新的函数。
委托
将一个子字段field的成员(field,method)都委托到当前层级。
The text was updated successfully, but these errors were encountered: