0

Kotlin设计模式

will created at6 years ago view count: 2953

地址: 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

过完语法看看这个

6 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: PrinterDriver@6ff3c5b5
Printing with object: PrinterDriver@6ff3c5b5
Printing with object: PrinterDriver@6ff3c5b5
6 years ago 回复

相关搜索关键词

Recent search keywords