Difference between revisions of "HasIndex"
Jump to navigation
Jump to search
(Created page with "<c>hashIndex</c> return whether the given index is valid for this object, that is, whether it could be used with square brackets to get some value from self. See also: In...") |
|
(No difference)
|
Revision as of 15:22, 17 March 2020
hashIndex
return whether the given index is valid for this object, that is, whether it could be used with square brackets to get some value
from self.
See also: Indexes
Arguments
Parameter Name | Default Value | Meaning |
---|---|---|
self | string, list, or map | object to check for an index on |
index | any | value to consider for possible index |
Usage Notes
When self is a list or string, the result is true for integers from -(length of string) to (length of string-1). When self is a map, it is true for any key (index) in the map. If called on a number, this method throws a runtime exception.
Example
"foo".hasIndex(2) // returns 1
"foo".hasIndex(3) // returns 0