AutoHotkey 中 Java 的 HashMap 的等价物是什么?
What is the equivalent of Java's HashMap in AutoHotkey?
我有一组缩写的部门名称。我需要创建一个脚本来将这些缩写与其官方名称对应起来。 (例如:管理员 → 管理)
在 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"));
}
AutoHotkey 中是否有相应的解决方案?
您可以使用 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}
这是一个数组,它使用作业的简称 (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"
我有一组缩写的部门名称。我需要创建一个脚本来将这些缩写与其官方名称对应起来。 (例如:管理员 → 管理)
在 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"));
}
AutoHotkey 中是否有相应的解决方案?
您可以使用 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}
这是一个数组,它使用作业的简称 (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"