Skip to content

Instantly share code, notes, and snippets.

@manoj-mili
Created November 8, 2021 18:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save manoj-mili/e043209caa25ee01f805fb8f8542f496 to your computer and use it in GitHub Desktop.
Save manoj-mili/e043209caa25ee01f805fb8f8542f496 to your computer and use it in GitHub Desktop.
Avoid Passing Too many arguments
// Don't pass too many arguments
fun saveUserDetails(
firstName: String,
lastName: String,
phoneNumber: String,
gender: String,
age: Int
) {}
// Do create a type and pass it as function param
data class User(
val firstName: String,
val lastName: String,
val phoneNumber: String,
val gender: String,
val age: Int
)
fun saveUserDetails(user: User) {}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment