[swift-users] Named parameters

Austin Zheng austinzheng at gmail.com
Sat Jan 23 14:05:16 CST 2016


Hi David,

The given rationale is that the first argument is often the "direct object" to a subject-verb phrase formed by a method call, and hence deserves privileged treatment. There's actually a thread going on in the swift-evolution mailing list about whether this should be changed.

Best,
Austin

> On Jan 23, 2016, at 12:02 PM, David Keck via swift-users <swift-users at swift.org> wrote:
> 
> Beginner here, so this may be obvious to some people, but I can't figure out why the first argument in a function call isn't referenced by name, but all subsequent ones are. I think I have the syntax down, but I just don't get why it is that way.
> 
> For example:
> func add(notRequired: Int, required: Int) -> Int {
> 	return notRequired + required
> }
> 
> let result = add(2, required: 5)
> // Not allowed:
> // let result = add(notRequired: 2, required: 5)
> 
> I just want to know the rationale behind this.
> _______________________________________________
> swift-users mailing list
> swift-users at swift.org
> https://lists.swift.org/mailman/listinfo/swift-users



More information about the swift-users mailing list