# Arrays

## Thing to learn

* [ ] Delete multiple items from an array

## Overview

* Groups data with square brackets "\[]"
* Indexes items from "0"
* It might be let or var
* It should contain one particular data type, whether it is string or number

### Data Types

* String
* Integer
* Double

Swift knows the data type of the array.

Arrays cannot mix multiple data types.

arrayName\<datatype>(): Creates an empty Array with defined data type&#x20;

### Actions

* **Add:** arrayName.append
* **Find**: arrayName\[indexnumber]
* **Count:** arrayName.count
* **Sort**: arrayName.sorted()
* ~~**Sort-Reverse**: arrayName.reversed() // It dows not work as expected. #learn~~
* **Check**: arrayName.contains("itemName")

## Sample Codes

### Removing or Appending a record to an Array

```swift
var numbers = [1,2,3]. // compile: [1, 2, 3]
numbers.append(4) // compile: [1, 2, 3, 4]
numbers.remove(at: 2) // compile: 3
print(numbers) // compile: "[1, 2, 4]\n"
```

### Counting

```swift
var deneme1 = ["ahmet","mehmet"]
deneme1.count // compile: 2

var deneme2 = "ahmet"
deneme2.count // compile: 5
// .count in Array's counts record but normally counts characters
```

## Sources

### Videos

### Articles / Documents

* <https://www.hackingwithswift.com/quick-start/beginners/how-to-store-ordered-data-in-arrays>
* <https://www.hackingwithswift.com/quick-start/beginners/how-to-check-a-condition-is-true-or-false>

## See Also

* [stride](https://swift.sedatonat.dev/codes/data-collectors/arrays/stride "mention")
