blob: 60a436289173c551f10e7a568e76b9f6b9ac8c77 [file] [log] [blame]
MG Mud User88f12472016-06-24 23:31:02 +02001SYNOPSIS
Zesstra715ec202025-07-09 22:18:31 +02002 mapping m_add(mapping map, mixed key, [mixed data...])
MG Mud User88f12472016-06-24 23:31:02 +02003
Zesstra715ec202025-07-09 22:18:31 +02004DESCRIPTION
5 Add (or replace) an entry with index <key> in mapping <map>.
6 The modified mapping is also returned as result.
Zesstra5481d492021-04-08 20:07:06 +02007
Zesstra715ec202025-07-09 22:18:31 +02008 The values for the entry are taken from the <data> arguments.
9 Unassigned entry values default to 0, extraneous <data> arguments
10 are ignored.
Zesstra5481d492021-04-08 20:07:06 +020011
Zesstra715ec202025-07-09 22:18:31 +020012 The difference between m_add() and the operator += is that for
13 the latter you might need to create a temporary mapping that
14 contains the entries to add, which m_add() doesn't.
MG Mud User88f12472016-06-24 23:31:02 +020015
Zesstra715ec202025-07-09 22:18:31 +020016EXAMPLES
MG Mud User88f12472016-06-24 23:31:02 +020017 mapping m;
Zesstra715ec202025-07-09 22:18:31 +020018
MG Mud User88f12472016-06-24 23:31:02 +020019 m = ([ "foo" ]);
20 m_add(m, "bar", 1) --> ([ "foo", "bar" ])
21
22 m = ([ "foo":1 ]);
23 m_add(m, "bar", 1) --> ([ "foo":1, "bar":1 ])
24
25 m = ([ "foo":1;2 ]);
26 m_add(m, "bar", 1) --> ([ "foo":1;2, "bar":1;0 ])
Zesstra715ec202025-07-09 22:18:31 +020027 m_add(m, "baz", ({ 4, 5 })... )
28 --> ([ "foo":1;2, "bar":1;0, "baz":4;5 ])
MG Mud User88f12472016-06-24 23:31:02 +020029
Zesstra715ec202025-07-09 22:18:31 +020030HISTORY
31 Introduced in LDMud 3.2.9.
MG Mud User88f12472016-06-24 23:31:02 +020032
Zesstra715ec202025-07-09 22:18:31 +020033SEE ALSO
MG Mud User88f12472016-06-24 23:31:02 +020034 mappingp(E), mkmapping(E), m_delete(E), m_entry(E), m_indices(E),
35 m_values(E), sizeof(E), widthof(E)