Remove attribute value

Syntax

$object.remove(`$attr`, $value)

Description

Removes a value value from a quantity-valued attribute attr of the object object.

Parameters

object name Type Type Description Mandatory Default
object Subject object

The object from which a value is to be removed from an attribute.

yes
attr Character string

The attribute literal of the attribute from which a value is to be removed.

yes
value Number/character string/truth value/object/quantity

The value or the set of values to be removed from the attribute of the object. If a set is specified, all contained values are removed.

yes

Examples

Remove individual value

	{
   obj = new(`my.module:MyType`);
   $obj.add(`my.module:MyType#items`, 'item1');
   $obj.add(`my.module:MyType#items`, 'item2');
   $obj.add(`my.module:MyType#items`, 'item3');
   $obj.remove(`my.module:MyType#items`, 'item2');
   $obj.get(`my.module:MyType#items`);
}

Output: A list with the elements ['item1', 'item3'].

After an object with three values was created, the value 'item2' was removed from the list.

Remove multiple values at the same time

	{
   obj = new(`my.module:MyType`);
   $obj.add(`my.module:MyType#tags`, 'important');
   $obj.add(`my.module:MyType#tags`, 'urgent');
   $obj.add(`my.module:MyType#tags`, 'review');
   $obj.add(`my.module:MyType#tags`, 'pending');
   $obj.remove(`my.module:MyType#tags`, ['urgent', 'pending']);
   $obj.get(`my.module:MyType#tags`);
}

Output: A list with the elements ['important', 'review'].

The values 'urgent' and 'pending' were removed from the list at the same time.

Remove non-existent value

	{
   obj = new(`my.module:MyType`);
   $obj.add(`my.module:MyType#items`, 'item1');
   $obj.add(`my.module:MyType#items`, 'item2');
   $obj.remove(`my.module:MyType#items`, 'nonexistent');
   $obj.get(`my.module:MyType#items`);
}

Output: A list with the elements ['item1', 'item2'].

The attempt to remove a non-existent value does not change the list and does not generate an error.