Set Literal Syntax

Originator:GriotSpeak
Number:rdar://17287811 Date Originated:2014-06-12
Status:Closed as duplicate Resolved:
Product:Developer Tools Product Version:
Classification: Reproducible:
 
Swift presents an opportunity to make Sets something closer to a first class collection type. While Dictionaries and Arrays are more commonly used than sets in Objective C, there are many cases where a Set is more desirable than either.  Core data uses sets extensively and the lack of a literal syntax, while manageable, is frustrating.

Set literal syntax would help to reduce the friction of using sets. 

Closure syntax allowing for 'bare' {} seems to preclude adopting python's set literal syntax, so I suggest <members>  

var array = ["foo", "bar", "foo", "baz"]
var dictionary = {"foo": "bar", "foo": "baz"}
var set = <"foo", "bar", "foo", "baz">

Comments


Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!