6 Storing data in dictionaries
This chapter covers
- Storing values on keys in dictionaries
- Working with pair objects
- Using tuples to create dictionaries
- Comparing dictionaries and arrays
- Comparing named tuples and dictionaries
This chapter introduces a new data type called a dictionary. In some other languages this datatype is also referred to as a map. In dictionaries, values are looked up by keys, as opposed to being looked up exclusively using integer indices, like in an array. The code example illustrates the difference. Each line performs the following operations:
-
Looking up the 42nd value x in array xs. Values in arrays are ordered. However, xs could have been a dictionary as well, since dictionary keys can be anything, including integers. ...
Get Julia as a Second Language now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.