Difference between revisions of "HasIndex"

From MiniScript Wiki
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...")
 
m (fixed typo)
 
(One intermediate revision by the same user not shown)
Line 1: Line 1:
<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
+
<c>hasIndex</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.   
 
from self.   
  

Latest revision as of 13:14, 19 June 2020

hasIndex 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