Pattern matching the fields of a map in erlang -


i'm reading book << programming erlang, 2nd edition >>. when looked through pattern matching of map's field, code snippet in book complains error on erlang prompt.

%% 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  %% eshell v6.2 65> henry8 = #{ class => king, born => 1491, died => 1547 }. #{born => 1491,class => king,died => 1547} 66> #{ born => b } = henry8. * 1: illegal pattern 

is there i'm missing? in advance.

use := instead of =>

#{ born := b } = henry8. 

source: http://erlang.org/doc/reference_manual/expressions.html#id79796


Comments

Popular posts from this blog

apache - PHP Soap issue while content length is larger -

asynchronous - Python asyncio task got bad yield -

javascript - Complete OpenIDConnect auth when requesting via Ajax -