Comments (7)
Those are the same – Type[]
is syntactic sugar for Array<Type>
.
I think we should go with Type[]
in the same way we write Int?
rather than Optional<Int>
. Arrays and optionals are so common that there are these (IMHO) readable and understandable shortcuts; we should use them!
from swift-style-guide.
Yes - syntax sugar is there for a purpose - we should use it.
from swift-style-guide.
Yeah the Apple book says to prefer using the Type[]
variant: "Although the two forms are functionally identical, the shorthand form is preferred, and is used throughout this guide when referring to the type of an array.”
from swift-style-guide.
Very good points, I think the parallel between this and Int?
vs Optional<Int>
is enough to end the discussion. Type[]
is definitely the way to go!
from swift-style-guide.
Just added this in 9932802. Thanks!
Of course, I had to say [Type]
rather than Type[]
now. ;]
from swift-style-guide.
Yep :] I think with the addition of the Dictionary sugar it makes even more sense to add a section on it. [Type]
looks soooo weird to me though...hope I'll get used to it soon!
from swift-style-guide.
The C++ style Foo<Bar>
is very familiar but I think I can see myself getting used to the new Swift style. I do like how the type declaration "looks like" the literal itself, which helps.
from swift-style-guide.
Related Issues (20)
- Exclusionary Language HOT 1
- same in Generics HOT 2
- In Multi-line String Literals, string color is different HOT 2
- Make the linter a dotfile HOT 2
- [email protected] HOT 1
- New line in functions. Not good. HOT 2
- Please add `no_extension_access_modifier` as a default SwiftLint rule HOT 1
- Please Add SwiftUI style guide
- https://ideas.accredible.com/changelog/functionality-for-a-messagenotification-to-be-added-over-an-issued-credential
- edge://credits/ HOT 1
- Clean code
- Function Declarations HOT 1
- 4-space indentation. HOT 2
- False positive from array_constructor custom rule
- how to write switch statement HOT 1
- Preferred type inference of static vars inside extensions HOT 4
- Pls update Readme file to reflect the newest changes in `if let` syntax introduced in Swift 5.7 HOT 1
- unused_import does not seem to be working HOT 1
- Function Calls vs Function Declarations HOT 2
- `unused_import` should be listed in the `analyzer_rules`
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from swift-style-guide.