Skip to content

Instantly share code, notes, and snippets.

@ch8n
Created July 30, 2019 11:46
Show Gist options
  • Save ch8n/5346af48f457495c538f89f5772b8dd1 to your computer and use it in GitHub Desktop.
Save ch8n/5346af48f457495c538f89f5772b8dd1 to your computer and use it in GitHub Desktop.
refactoring Error Destrcurting
//Gotcha #5 refactoring issue/ no compileTimeCheck
data class ContactMe(val email: String, val phone: String, val twitter: String)
val contact = ContactMe("[email protected]","999999999","ch8n2@twitter")
//destructing
val (email,phone,twitter) = contact
data class ContactMe(val email: String, val phone: String, val medium:String,val twitter: String)
val contact = ContactMe("[email protected]","999999999","ch8n@medium","ch8n2@twitter")
//destructing
val (email,phone,twitter) = contact // it will compile but twitter with have value "ch8n@medium"
//this behavious is again the cause of positional destructing
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment