Errlang: no match of right hand side value

前端 未结 1 1315
迷失自我
迷失自我 2021-01-18 19:02

I\'m getting started with Erlang, but I\'m already in troubles. I copied this example from a book:

-module(echo).
-export([start/0, loop/0]).

start() ->
         


        
相关标签:
1条回答
  • 2021-01-18 19:32

    Probably, 'Pid' has some value assigned already and you're trying to re-assign it.

    Here is how it behaves on my machine:

    Eshell V5.9.1  (abort with ^G)
    1> c(echo).
    {ok,echo}
    2> f.
    f
    3> Pid = echo:start().
    <0.39.0>
    4> Pid = echo:start().
    ** exception error: no match of right hand side value <0.41.0>
    5>
    

    As you can see, the first 'Pid = ' construction woks fine, but the second one throws error message you described.

    I think, you used Pid in the shell before already and it has some value assigned.

    Try to 'reset' Pid variable and use it like following:

    8> f(Pid).
    ok
    9> Pid.
    * 1: variable 'Pid' is unbound
    10> Pid = echo:start().
    <0.49.0>
    

    Or you can forget all variables by using such a construction:

    13> f().
    ok
    14> Pid = echo:start().
    <0.54.0>
    

    Pay attention on used f(). - not just f.

    0 讨论(0)
提交回复
热议问题