Swift - Dictionaries: Unterschied zwischen den Versionen

Aus Wikizone
Wechseln zu: Navigation, Suche
 
Zeile 1: Zeile 1:
 +
== Links ==
 +
[[Swift]]
 +
== Beispiele ==
 
<syntaxhighlight lang="swift">
 
<syntaxhighlight lang="swift">
 
import UIKit
 
import UIKit

Aktuelle Version vom 29. Dezember 2022, 15:38 Uhr

Links[Bearbeiten]

Swift

Beispiele[Bearbeiten]

import UIKit

studentsAndScores["Max"] = 65
print("Number of students: \(studentsAndScores.count)")
print("Keys: \(studentsAndScores.keys) - note that the order is different each time")
showScores(scores:studentsAndScores)
print("James Score is: \(studentsAndScores["James"]!)")
highestScore(scores: studentsAndScores)

func showScores(scores: [String: Int]){
    for score in scores {
        print(" \(score.key) \(score.value)")
    }
}

func highestScore(scores: [String: Int]) {
    var highest = scores.values.max()
    print(highest ?? 0)
}