Answer the question
In order to leave comments, you need to log in
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
docs
for element in array {
if element < min {...}
...
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question