[swift-users] Named parameters
Zbyňa
zbynek.fiala at gmail.com
Sat Jan 23 14:14:26 CST 2016
It has origin in Obj C:
excelent explaining here:
http://stackoverflow.com/questions/24680771/using-function-parameter-names-in-swift
Dne 23.1.2016 v 21:02 David Keck via swift-users napsal(a):
> 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