HasIndex

From MiniScript Wiki
Revision as of 17:34, 16 March 2020 by 71.226.33.30 (talk) (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...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

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