Skip to content

Modern Map Add

Paul Squires edited this page Oct 19, 2026 · 5 revisions

Home › Map › Map › Add

Add

Adds a key and value if the key is new; an existing value is left alone.

Syntax

Add( k, v ) as boolean

Examples

#import "std/containers"
using containers

dim ages as Map( of ustring, integer )

print ages.Add( "ada", 36 )      '' true -- inserted
print ages.Add( "ada", 99 )      '' false -- already there, NOT overwritten
print ages[ "ada" ]              '' 36 -- the original value survives

'' That refusal is the whole difference from Put

Library: Map
Category: Map
Documented under: Members

Clone this wiki locally