Re:Objective-C literals for NSDictionary, NSArray, and NSNumber
by bebop on Sunday February 19, 2012 @03:59PM
(#3610387)
I think they chose the [] for arrays and {} for dictionaries as that is the style that seems to be most popular right now. Python for instance uses this.
[ Parent
| on HN ]
Re:Objective-C literals for NSDictionary, NSArray, and NSNumber
by openbear on Sunday February 19, 2012 @11:56PM
(#3611351)
When adding features to something, I tend to be a big fan of "when in Rome"[1]. If these were extensions to Python (or Ruby or JavaScript) then I would totally be for using '[' with arrays. As a C guy though, I would rather have seen them use '{' for NSArray and '[' for NSDictionary. Regardless, I'm glad to see this stuff added.
[1] http://en.wiktionary.org/wiki/when_in_Rome,_do_as_the_Romans...
Re:Objective-C literals for NSDictionary, NSArray, and NSNumber
by xsmasher on Monday February 20, 2012 @02:10AM
(#3611617)
It's already custom in objc to use {} for dicts and [] for arrays when printing them out, unless I'm misremembering. It also matches the use of those characters in JSON, so it seems natural to me.