Skip to content

cotrVarMap

Creates a dictionary variable

Aliases:

  • cotrVarMap
  • createMap
  • createStruct
  • variableMap
  • variableStruct
  • mapVariable
  • structVariable
  • dictVariable
  • variableDict
  • createDict

cpp

std::map<keyType, valueType> myMap = {
{key1, value1},
{key2, value2},
// Add more key-value pairs here
};

csharp

Dictionary<Key, Value> myDict = new Dictionary<Key, Value>();

dart

Map<KeyType, ValueType> myMap = {
key1: value1,
key2: value2
};

go

var mapName = map[keyType]valueType{
key1: value1,
key2: value2
}

haskell

let myMap = Map.fromList [(key, value)]
-- Add more key-value pairs here

java

Map<Key, Value> myMap = new HashMap<>();
myMap.put(key, value);

javascript

let myObject = {
'key1': 'value1',
'key2': 'value2'
};

javascriptreact

let myObject = {
'key1': 'value1',
'key2': 'value2'
};

kotlin

var myMap = mapOf(
'key1' to 'value1',
'key2' to 'value2',
// Add more key-value pairs here
)

perl

my %myHash = (key => value);

php

myMap = [key => value];

powershell

Terminal window
myHashTable = @{
key1 = value1
key2 = value2
# Add more key-value pairs here
}

python

myDict = {
'key1': value1,
'key2': value2
}

ruby

my_hash = {
key1: value1,
key2: value2,
# Add more key-value pairs here
}

rust

use std::collections::HashMap;
let myMap = HashMap::new();

scala

val myMap = Map(key -> value)

shellscript

Terminal window
# Create an associative array (map):
declare -A myMap
myMap[key1]=value1
myMap[key2]=value2

swift

var myDictionary = [
'key1': 'value1',
'key2': 'value2'
];

typescript

let myMap: { [key: string]: type } = {
'key1': 'value1',
'key2': 'value2',
// Add more key-value pairs here
};

typescriptreact

let myMap: { [key: string]: type } = {
'key1': 'value1',
'key2': 'value2',
// Add more key-value pairs here
};