A
A
Aleksandr Govorukhin2015-10-28 19:53:35
iOS
Aleksandr Govorukhin, 2015-10-28 19:53:35

How to compare array elements in swift?

Hello! I'm just starting to learn a programming language and I need your help.
var array: [Int] = []
var min: Int = 0
for i in 1...10 {
array.append(Int(arc4random_uniform(10) + 1))
}
for i in array {
if array.i < min {
min = array[i]
}
}
how to compare array elements? How to access an element? Please write these lines, it will not take you much time, but help me out a lot.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Alexander Tikhonov, 2015-10-28
@SnapSh0t

docs

for element in array { 
if element < min {...}
...
}

NatashaTheRobot

A
AmikoYuki, 2015-10-28
@AmikoYuki

Why ask a question that has an answer in a language book? Read it and the truth will be revealed to you, and if not, then programming is not for you. And you should remove "Apple developer" from your signature.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question