简体   繁体   English

AutoHotkey中的Java HashMap等效于什么?

[英]What is the equivalent of Java's HashMap in AutoHotkey?

I have a set of abbreviated department names. 我有一组缩写的部门名称。 I need to create a script which can map these abbreviations with their official titles. 我需要创建一个脚本,以将这些缩写与它们的正式名称进行映射。 (For example: ADMIN → Administration) (例如:ADMIN→管理)

In Java I could accomplish this using a HashMap . 在Java中,我可以使用HashMap完成此操作。

public static void main() {
   HashMap hm = new HashMap(); // create hash map

   hm.put("ADMIN", "Administration");  // add elements to hashmap
   hm.put("RAD",   "Radiologist");
   hm.put("TECH",  "Technician");

   System.out.println("ADMIN is an abbreviation for " + hm.get("ADMIN"));
}

Is there an equivalent solution for this in AutoHotkey? 在AutoHotkey中是否有与此等效的解决方案?

You can implement key-value pairs using an Associative Array 您可以使用关联数组实现键值对

An associative array is an object which contains a collection of unique keys and a collection of values, where each key is associated with one value. 关联数组是一个对象,其中包含唯一键的集合和值的集合,其中每个键与一个值关联。 Keys can be strings, integers or objects, while values can be of any type. 键可以是字符串,整数或对象,而值可以是任何类型。 An associative array can be created as follows: 可以如下创建一个关联数组:

 Array := {KeyA: ValueA, KeyB: ValueB, ..., KeyZ: ValueZ} 

Here is an array which uses a job's shortened name ( key ) to find the full display name ( value ). 这是一个使用作业的简称( key )查找完整显示名称( value )的数组。

JobArray := {ADMIN:"Administration", TECH:"Technician", RAD:"Radiologist"}

; Check if key is present
if (JobArray.HasKey("ADMIN"))
    MsgBox, % "ADMIN is an abbreviation for " . JobArray["ADMIN"]
else
    MsgBox, % "No display name found"

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM