Question

We are having a naming issue. if we have dictionary:

dictionary[key]

or a list

list[1]
list[3:4]
list[:3]

what are the names of the words inside "[" "]", accessors? parameters? keys?

Était-ce utile?

La solution

Regarding a dictionary, the name given to the value within the square brackets is a key. This is because a Dictionary is a key-value pair repository. An example of this use can be found in Microsoft's definition of a Dictionary item property here.

For a list, the name given to the value within the square brackets is an index. This is because it is used to select an item from the list at the specified (usually zero-based) index. Again, an example of this naming convention can be found here.

Note that whilst I have included links to Microsoft documentation in this answer, the use of "key" and "index" for dictionaries and lists (respectively) is a convention used through most, if not all, programming languages.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top