Opened 4 months ago

Last modified 4 months ago

#3969 new Feature Request

Map Initializer List

Reported by: anonymous Owned by:
Milestone: Component: AutoIt
Version: Severity: None
Keywords: Map, Initializer List Cc:

Description (last modified by mLipok)

; For Arrays, we can use
Global $a = [1, 2, 3]
; or
Global $a[] = [1, 2, 3]
; or
Global $a[3] = [1, 2, 3]

; But if we create a Map, it is always empty, and there is no good way to initialize Maps. So here is a suggestion:

Global $a["key1", "key2", "key3"] = [1, 2, 3]

; is the same as

Global $a[]
$a["key1"] = 1
$a["key2"] = 2
$a["key3"] = 3

; I'm sure we do not "need" this feature, but it would be nice to have. (the same argument could be made for Array-Initialization with initializer list... we do not "need" it, but it is nice that it exists)

Attachments (0)

Change History (2)

comment:1 Changed 4 months ago by anonymous

; Addition: If the right side is missing, the map is initialized with empty strings for every key.

Global $a["key1", ..., "keyN"]
If MapExists($a, "key1") -> True.

; This enables compact and easy to use string lookup-tables.

comment:2 Changed 4 months ago by mLipok

  • Description modified (diff)

Guidelines for posting comments:

  • You cannot re-open a ticket but you may still leave a comment if you have additional information to add.
  • In-depth discussions should take place on the forum.

For more information see the full version of the ticket guidelines here.

Add Comment

Modify Ticket

as new The ticket will remain with no owner.

E-mail address and user name can be saved in the Preferences.

Note: See TracTickets for help on using tickets.