Kotlin Classes and Objects
fun main(args: Array<String>) {
UseFactory.post("Howdy")
UseFactory.post("Howdy Partner")
UseFactory.post("How are you")
}
class Factory private constructor(var message:String){
init {
println("Factory Inited! $message")
}
companion object {
fun create(message: String): Factory = Factory(message)
}
fun post(another: String) {
println(another)
}
}
object UseFactory {
val factory = Factory.create("Hello Kotlin")
fun post(another: String) = factory.post(another)
}