Smalltalk - 将字母数字作为键的字典等效词?

MrD*_*Duk 2 smalltalk

是否有一个词典等价物将接受字母数字作为关键?花了一些时间在这里让你们帮助分配UUID值,我现在意识到Dictionaries只采用整数.我曾计划使用UUID作为密钥.

我的设计是为总帐 - 我的分类帐成员初始化为ledger := Dictionary new,我希望做的事情符合以下方面:

postTransaction: GLEntry
    ledger at: GLEntry UID put: GLEntry
Run Code Online (Sandbox Code Playgroud)

Bob*_*ica 11

字典可以使用您喜欢的任何键作为键.在字典中使用字符串键很常见.例如,在Dolphin Smalltalk v6.x中评估以下内容:

d := Dictionary new.

d
  at: 'a' put: 'a string';
  at: 'b' put: 'b string';
  at: 'c' put: 'c string'.

Transcript
  show: (d at: 'a'); cr;
  show: (d at: 'b'); cr;
  show: (d at: 'c'); cr
Run Code Online (Sandbox Code Playgroud)

会导致

a string
b string
c string
Run Code Online (Sandbox Code Playgroud)

显示在Transcript窗口中.

分享和享受.