Skip to content

Instantly share code, notes, and snippets.

@intrepidmatt
Created June 12, 2014 19:32
Show Gist options
  • Select an option

  • Save intrepidmatt/658c3b4bdae320946c1b to your computer and use it in GitHub Desktop.

Select an option

Save intrepidmatt/658c3b4bdae320946c1b to your computer and use it in GitHub Desktop.
Swift Parameter Name Conventions Are Dumb
class Person {
let name: String
let age: Int
init(name: String, age: Int) {
self.name = name
self.age = age
}
class func createPerson(name: String, age: Int) -> Person {
var person = Person(name: name, age: age)
return person
}
}
func createPerson(name: String, age: Int) -> Person {
var person = Person(name: name, age: age)
return person
}
var usingConstructor = Person(name: "Matt", age: 34)
var usingFactory = Person.createPerson("Matt", age: 34)
var usingFunction = createPerson("Matt", 34)
//var usingConstructor = Person("Matt", 34) // No!
//var usingConstructor = Person("Matt", age: 34) // Bad!
//var usingFactory = Person.createPerson("Matt", 34) // Nope!
//var usingFactory = Person.createPerson(name: "Matt", age: 34) // Error!
//var usingFunction = createPerson(name: "Matt", age: 34) // No way!
//var usingFunction = createPerson("Matt", age: 34) // Don't even try it!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment