Perhaps instead of "auto" we could allow "lazy" to create a default lazy constructor for these cases ?
On Tue, Jan 5, 2016 at 12:39 PM, James Campbell <[email protected]> wrote: > See this code: > > var distanceCache: [Int: Int] = Dictionary<Int, Int>() > It is very long and tedious to write especially if what I am storing > changes. > > I propose we be allowed to do the following: > > *var distanceCache: [Int: Int] = []* > > If this isn't possible then I wouldn't mind having some way of telling the > compiler to auto create it like so: > > *var distanceCache: [Int: Int] ()* > > or > > *var distanceCache: [Int: Int] = new Dictionary* > > or even: > > *var distanceCache: [Int: Int] = auto* > > *auto var distanceCache: [Int: Int]* > > (auto short for auto create) > > > Perhaps this dictionary syntax is just confusing and it was a bad idea to > make it the same as an array. Most languages use "{" so why did swift > choose to share "[" with arrays and dictionaries. > -- > Wizard > [email protected] > +44 7523 279 698 > -- Wizard [email protected] +44 7523 279 698
_______________________________________________ swift-evolution mailing list [email protected] https://lists.swift.org/mailman/listinfo/swift-evolution
