- 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.
推薦閱讀
- RCNP實驗指南:構建高級的路由互聯網絡(BARI)
- 物聯網網絡安全及應用
- Oracle SOA Suite 11g Performance Tuning Cookbook
- 計算機網絡安全實訓教程(第二版)
- Building RESTful Web Services with Spring 5(Second Edition)
- 新手易學:新手學淘寶開店
- TD-LTE無線網絡規劃與設計
- 物聯網工程導論(第3版)
- 現代通信系統(第5版)
- 園區網絡架構與技術
- Selenium WebDriver 3 Practical Guide
- 圖神經網絡前沿
- 移動互聯網環境下的核心網剖析及演進
- 中國信息化年鑒2017
- Migrating to Drupal7