What is the new keyword?

I read The Swift Programming Language iBook . In the keywords section they are listed new . But in the Summary of the Grammar section, I did not find it.

What is new used in Swift for?

+6
source share
2 answers

It seems to be deleted.

I tried let x = new Double[2] but in Xcode 7 it now throws an error

Playground execution failed: OSX.playground: 1: 9: error: use of unresolved identifier "new" let a = new [Double]

+2
source

It seems that new can be used to create an array:

 let x = new Double[2] x[0] = 3.1 x[1] = 4.2 println(x) // Output: [3.1, 4.2] 

But this is only a theoretical interest. It is not documented and therefore should not be b.

+5
source

Source: https://habr.com/ru/post/971240/


All Articles