[swift-evolution] Colon vs. equals

Radosław Pietruszewski radexpl at gmail.com
Mon Feb 8 13:56:27 CST 2016


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 at 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 at swift.org
> https://lists.swift.org/mailman/listinfo/swift-evolution



More information about the swift-evolution mailing list