.values
Anonymous contributor
Published Sep 18, 2024
Contribute to Docs
The .values
property in Swift is used to access a collection of all the values stored in a key-value dictionary.
Syntax
dictionaryName.values
dictionaryName
: Refers to the dictionary instance from which the values are accessed.
Example
The code below creates a dictionary with key-value pairs and then uses the .values
property to print only the values from the dictionary:
var worldCupWinners = ["Argentina": 2022,"France": 2018,"Germany": 2014,"Spain": 2010,]print(worldCupWinners.values)
The code above generates the following output:
[2010, 2022, 2018, 2014]
Note: The values will be printed in a random order.
All contributors
- Anonymous contributor
Contribute to Docs
- Learn more about how to get involved.
- Edit this page on GitHub to fix an error or make an improvement.
- Submit feedback to let us know how we can improve Docs.