- iOS 12 Programming for Beginners
- Craig Clayton
- 114字
- 2021-07-02 15:04:59
Creating an array with initial values
Arrays can have initial values when they are created. Let's see how this would look by entering the following in Playgrounds:
let integers2 = [54, 29]
Your code will now look like this:

The array that we just entered uses type inference to declare the data type of the array using its initial values. In this case, Swift understands that it is an array of ints because the values we entered are integers. In addition, when we use a constant (let) on an array, we are telling Swift that the array is an immutable array, which means that the contents or size cannot change once it is instantiated.
推薦閱讀
- Modern JavaScript Web Development Cookbook
- GPS/GNSS原理與應用(第3版)
- SEO 20日
- 網絡互聯技術(實踐篇)
- SSL VPN : Understanding, evaluating and planning secure, web/based remote access
- 城域網與廣域網(第2版)
- 6G:面向2030年的移動通信
- 物聯網與智能家居
- 網管第一課:網絡操作系統與配置管理
- 5G+區塊鏈
- Hands-On Bitcoin Programming with Python
- 5G技術核心與增強:從R15到R17
- Professional Scala
- 無線傳感器網絡定位方法及應用
- Learning IoT with Particle Photon and Electron