0

What's the difference between these 3:

struct A {
  let myVal: Array<Char>
  let myVal2: [char]
  let myVal3: Array<CChar>
}

Which one is more common or recommended to be used?

2 Answers 2

3

There is no difference between Array<Thing> and [Thing]; the latter is syntactic sugar for the former.

Hence the only difference between your three declarations is the difference between the three element types: Char (whatever that is), char (whatever that is - a type name starting with a small letter is really bad practice in Swift, though), and CChar (that's the only one I've ever heard of). The recommended one of those three is: whatever it is you want an array of.

Sign up to request clarification or add additional context in comments.

Comments

0

CChar is Swift equivalent of C Primitive type - It is recommended to use Swift data type where it is possibl.- Apple Documentation

The recommended usage as per this style guide is the shortcut version

myValue: [CChar]

Hope this helps

Comments