[erlang-questions] Strange matching behavior

block.rxckin.beats <>
Thu Sep 5 09:39:04 CEST 2019


I found strange behavior, see code below.

why last match doesn't works ?


```main.erl
#!/usr/bin/env escript
-module(main).

-mode(compile).
-compile(export_all).

xy() ->
    #{ 160506610  => x, 3960650446 => y }.

x() ->
    #{ 160506610  => x }.

y() ->
    #{ 3960650446 => y }.

xy2() ->
    #{ 888888888  => x, 9999999999 => y }.

main(_) ->
    #{ 160506610  := x } = xy(), % ok
    #{ 3960650446 := y } = xy(), % ok

    #{ 160506610  := x } = x(), % ok
    #{ 3960650446 := y } = y(), % ok


    #{ 888888888  := x,
       9999999999 := y
     } = xy2(), % ok


    #{ 160506610  := x,
       3960650446 := y
     } = xy(), % no match of right hand side value, WHY ??

    ok.
```

Erlang: Erlang/OTP 22 [erts-10.4] [source] [64-bit] [smp:8:8] [ds:8:8:10]
[async-threads:1] [hipe]
OS: Ubuntu 19.04 disco
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20190905/c7dcfb3a/attachment.html>


More information about the erlang-questions mailing list