Colon vs. equals

My interpretation:

1. “foo: bar” means “foo is bar”
2. “foo = bar” means “assign bar to foo”

So (2) should only be used for assignment to variables/constants, and when assigning default values to function parameters. (1) is more versatile and should be used in all other contexts.

IMHO:

@available(iOS, introduced=7.0, deprecated=8.0)

should be changed to:

   @available(iOS, introduced: 7.0, deprecated: 8.0)

But aside from that, I don’t have beef with the colon being used in different contexts — looks cleaner and nicer than ` = ` to my eyes.

— Radek

···

On 06 Feb 2016, at 00:27, Brent Royal-Gordon via swift-evolution <swift-evolution@swift.org> wrote:

This is perhaps a bit nitpicky, but I've noticed that Swift sometimes uses colon to separate names and values, and sometimes uses equals. It's vaguely maddening.

What do I mean? Well, our language has this:

  myFunc(foo, bar: baz)

But it also has:

  @available(iOS, introduced=7.0, deprecated=8.0)

You create a dictionary like this:

  let dict = ["key": "value"]

But you set it like this:

  dict["key"] = "value"

Is there some principle here? The @available case seems particularly strange to me, because those values read strongly like parameters to me.

--
Brent Royal-Gordon
Architechies

_______________________________________________
swift-evolution mailing list
swift-evolution@swift.org
https://lists.swift.org/mailman/listinfo/swift-evolution