模式匹配 erlang 中地图的字段

Pattern matching the fields of a map in erlang

我正在阅读《Programming Erlang,第 2 版》一书。当我查看 Map 字段的模式匹配时,书中的代码片段在我的 Erlang 提示符下抱怨一些错误。

%% Book's version
1> Henry8 = #{ class => king, born => 1491, died => 1547 }. 
#{ born => 1491, class=> king, died => 1547 }.
2> #{ born => B } = Henry8.
#{ born => 1491, class=> king, died => 1547 }.
3> B.
1491

%% My Eshell V6.2
65> Henry8 = #{ class => king, born => 1491, died => 1547 }.
#{born => 1491,class => king,died => 1547}
66> #{ born => B } = Henry8.
* 1: illegal pattern

有什么我遗漏的吗?提前致谢。

使用 := 代替 =>

#{ born := B } = Henry8.

来源:http://erlang.org/doc/reference_manual/expressions.html#maps-in-patterns