0

Kotlin设计模式

will created at5 years ago view count: 2732

地址: https://github.com/dbacinski/Design-Patterns-In-Kotlin

包含了一些最常用的设计模式

  • Behavioral Patterns
    • Observer / Listener
    • Strategy
    • Command
    • State
    • Chain of Responsibility
    • Visitor
  • Creational Patterns
    • Builder / Assembler
    • Factory Method
    • Singleton
    • Abstract Factory
  • Structural Patterns
    • Adapter
    • Decorator
    • Facade
    • Protection Proxy
report
回复
0

过完语法看看这个

5 years ago 回复
0

原来单例模式直接一个关键词就搞定了。。。

object PrinterDriver {
    init {
        println("Initializing with object: $this")
    }

    fun print() = println("Printing with object: $this")
}

println("Start")
PrinterDriver.print()
PrinterDriver.print()
Start
Initializing with object: [email protected]
Printing with object: [email protected]
Printing with object: [email protected]
5 years ago 回复

相关搜索关键词

Recent search keywords