Skip to content

GitLab

  • Menu
Projects Groups Snippets
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • ion ion
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 84
    • Issues 84
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 3
    • Merge requests 3
  • Deployments
    • Deployments
    • Releases
  • Packages & Registries
    • Packages & Registries
    • Container Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Commits
  • Issue Boards
Collapse sidebar
  • redox-os
  • ionion
  • Issues
  • #246
Closed
Open
Created Mar 14, 2017 by Michael Aaron Murphy@mmstickMaintainer

Associative Arrays (HashMaps)

Here's a syntax we could use for associative array creation:

$ let hashmap = [ '&red=F00' '&blue=00F' ]
$ echo @hashmap['red']
FOO

And each associative array may contain further sub-elements:

$ let hashmap = [ '&user1={ &name="Michael" &id="1624" }' ]
$ echo @hashmap['user1']
> &name="Michael" &id="1624"
$ echo @hashmap['user1']['name']
> Michael

Sub-elements could be interpreted as arrays

$ let hashmap = [ '&users={&user1="1" &user2="2" &user3="3"}' ]
$ for user in @hashmap['users']
$   echo $user
$ end
> &user1="1"
> &user2="2"
> &user3="3"

Sub-elements may even be arrays themselves

$ let hashmap = [ '&team1=["12" "23" "21" "8"]' '&team2=["24" "8" "12" "30"]' ]
$ for score in @hashmap['team1']; echo $score; end
> 12
> 23
> 21
> 8
$ for score in @hashmap['team2']; echo $score; end
> 24
> 8
> 12
> 30
Assignee
Assign to
Time tracking