문제

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?

도움이 되었습니까?

해결책

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.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top