Method `->()
- Method
`->
mixed`->(objectarg,stringindex)
mixed`->(intarg,stringindex)
mixed`->(arrayarg,stringindex)
mixed`->(mappingarg,stringindex)
bool`->(multisetarg,stringindex)
mixed`->(programarg,stringindex)- Description
Arrow indexing.
Every non-lvalue expression with the
->operator becomes a call to this function.a->bis the same aspredef::`^(a,"b")where"b"is the symbolbin string form.This function behaves like `[], except that the index is passed literally as a string instead of being evaluated.
- Returns
If
argis an object that implements lfun::`->(), that function will be called withindexas the single argument.Otherwise the result will be as follows:
argcan have any of the following types:objectThe non-protected (ie public) symbol named
indexwill be looked up inarg.intThe bignum function named
indexwill be looked up inarg.arrayAn array of all elements in
argarrow indexed withindexwill be returned.mappingIf
indexexists inargthe corresponding value will be returned. OtherwiseUNDEFINEDwill be returned.multisetIf
indexexists inarg,1will be returned. OtherwiseUNDEFINEDwill be returned.programThe non-protected (ie public) constant symbol
indexwill be looked up inarg.- Note
In an expression
a->b, the symbolbcan be any token that matches the identifier syntax - keywords are disregarded in that context.- Note
An arrow indexing expression in an lvalue context, i.e. where the index is being assigned a new value, uses `->= instead of this function.
- See also