Last active
March 6, 2022 23:01
-
-
Save evilthreads669966/05da7323d179fab3e5a37a2d8b91ed89 to your computer and use it in GitHub Desktop.
builder
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fun main() { | |
val builder = Sms.Builder() | |
val message = builder.from("5127208800").to("9727404318").body("Hey, what's up?").build() | |
message.send() | |
} | |
data class Sms private constructor(var to: String, var from: String, var body: String){ | |
fun send(){}//TODO() | |
class Builder{ | |
private val message = Sms("","","") | |
fun to(to: String) = this.apply { message.to = to } | |
fun from(from: String) = this.apply { message.from = from } | |
fun body(body: String) = this.apply { message.body = body } | |
fun build() = message | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment