Method `->=()
- Method `->=
mixed
`->=(object
arg
,string
index
,mixed
val
)
mixed
`->=(mapping
arg
,string
index
,mixed
val
)
bool
`->=(multiset
arg
,string
index
,bool
val
)- Description
Arrow index assignment.
Every lvalue expression with the
->
operator becomes a call to this function, i.e.a->b=c
is the same aspredef::`->=(a,"b",c)
where"b"
is the symbolb
in string form.This function behaves like `[]=, except that the index is passed literally as a string instead of being evaluated.
If
arg
is an object that implements lfun::`->=(), that function will be called withindex
andval
as the arguments.arg
can have any of the following types:object
The non-protected (ie public) variable named
index
will be looked up inarg
, and assignedval
.array
|mapping
Index
index
inarg
will be assignedval
.multiset
If
val
is0
(zero), one occurrance ofindex
inarg
will be removed. Otherwiseindex
will be added toarg
if it is not already there.- Returns
val
will be returned.- Note
In an expression
a->b=c
, the symbolb
can be any token that matches the identifier syntax - keywords are disregarded in that context.- Note
An arrow indexing expression in a non-lvalue context, i.e. where the index is being queried instead of assigned, uses `-> instead of this function.
- See also