Skip to content

Instantly share code, notes, and snippets.

@evilthreads669966
Last active March 6, 2022 23:01
Show Gist options
  • Save evilthreads669966/05da7323d179fab3e5a37a2d8b91ed89 to your computer and use it in GitHub Desktop.
Save evilthreads669966/05da7323d179fab3e5a37a2d8b91ed89 to your computer and use it in GitHub Desktop.
builder
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