Skip to content

Proper way to MAP #842

Answered by krakxn
Mark-Four asked this question in Q&A
Jul 9, 2022 · 2 comments · 6 replies
Discussion options

You must be logged in to vote

I will keep this as simple as possible for beginners:

The first way - think of the mapping nameToFavoriteNumber as a kind of dictionary; with name as key, which points to the data (here, favouriteNumber) which it contains. And you can access that data by doing nameToFavoriteNumber[key] (which is essentially calling the key which points to our data).
Now to be precise, since we are using the assignment operator = here, it assigns _favoriteNumber (or data) to the key _name (or our key)

Example (visual representation for interpretation, not precise):
nameToFavoriteNumber["Alice"] = 7
nameToFavoriteNumber = {"Alice": 7} // Alice points to 7 (Alice ----> 7) inside our mapping

The second way - …

Replies: 2 comments 6 replies

Comment options

You must be logged in to vote
2 replies
@Mark-Four
Comment options

@krakxn
Comment options

Answer selected by alymurtazamemon
Comment options

You must be logged in to vote
4 replies
@Mark-Four
Comment options

@alymurtazamemon
Comment options

@krakxn
Comment options

@Mark-Four
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants