"New dictionary"의 두 판 사이의 차이

98번째 줄: 98번째 줄:
</source>
</source>


==See also==
==같이 보기==
*[[array]]
*[[array]]
*[[array_combine]]
*[[array_combine]]
*[[del]]
*[[del]]
*[[localStorage]]
*[[localStorage]]

2014년 5월 22일 (목) 23:25 판

Associative arrays
hash map
hash table
Dictionary
NSDictionary
NSMutableDictionary

1 Bash

declare -A DICT
DICT["ID"]=102
DICT["Name"]="YONEZAWA Akinori"
DICT["Address"]="Naha, Okinawa"

2 C#

Hashtable ht = new Hashtable();
ht.Add("ID", "102");
ht.Add("Name", "YONEZAWA Akinori");
ht.Add("Address", "Naha, Okinawa");
Dictionary<string, string> dic = new Dictionary<string, string>();
dic.Add("ID", "102");
dic.Add("Name", "YONEZAWA Akinori");
dic.Add("Address", "Naha, Okinawa");
Dictionary<int, string> = new Dictionary<int, string> {
  { "ID", "102" },
  { "Name", "YONEZAWA Akinori" },
  { "Address", "Naha, Okinawa" }
};

3 Java

HashMap<String,Object> map = new HashMap<String,Object>();
map.put("ID", "102");
map.put("Name", "YONEZAWA Akinori");
map.put("Address", "Naha, Okinawa");
System.out.print("map", map.toString());
// {Name=YONEZAWA Akinori, ID=102, Address=Naha, Okinawa}

4 JavaScript

var dic = {
'ID' : '102',
'Name' : 'YONEZAWA Akinori',
'Address' : 'Naha, Okinawa'
};
console.log(dic);
// Object {ID: "102", Name: "YONEZAWA Akinori", Address: "Naha, Okinawa"}
var dic = new Object();
dic['ID'] = "102";
dic['Name'] = "YONEZAWA Akinori";
dic['Address'] = "Naha, Okinawa";
console.log(dic);
// Object {ID: "102", Name: "YONEZAWA Akinori", Address: "Naha, Okinawa"}

5 Objective-C

NSMutableDictionary *dic = [[NSMutableDictionary alloc] init];
[dic setObject:@"102" forKey:@"ID"];
[dic setObject:@"YONEZAWA Akinori" forKey:@"Name"];
[dic setObject:@"Naha, Okinawa" forKey:@"Address"];

6 PHP

$dict = array(
  "ID" => 102,
  "Name" => "YONEZAWA Akinori",
  "Address"=> "Naha, Okinawa"
);

7 Python

dict = { 'ID' : 102, 'Name' : 'YONEZAWA Akinori', 'Address' : 'Naha, Okinawa' }
fruits = { 'a' : 'apple', 'b' : 'banana', 'c': 'cranberry' }

8 같이 보기