rec.name := obj O
The record assignment assigns the object obj, which may be an object of arbitrary type, to the record component with the name name, which must be an identifier, of the record rec. That means that accessing the element with name name of the record rec will return obj after this assignment. If the record rec has no component with the name name, the record is automatically extended to make room for the new component.
gap> r := rec( a := 1, b := 2 );; gap> r.a := 10;; r; rec( a := 10, b := 2 ) gap> r.c := 3;; r; rec( a := 10, b := 2, c := 3 )
Note that assigning to a record changes the record.
The function IsBound can be used to test if a record
has a component with a certain name, the function Unbind (see Unbind)
can be used to remove a component with a certain name again.
gap> IsBound(r.a); true gap> IsBound(r.d); false gap> Unbind(r.b);r; rec( a := 10, c := 3 )
rec.(name) := obj O
This construct is similar to the above construct. The difference is that the second operand name is evaluated. It must evaluate to a string or an integer otherwise an error is signalled. The construct then assigns obj to the record component of the record rec whose name is, as a string, equal to name.
[Top] [Previous] [Up] [Next] [Index]
GAP 4 manual