Dummy question

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Dummy question

Donald Steven
(LOL)

I want to initiate a function parameter in the calling code to 0, as in:

myfun(0, ....) ->

The parameter won't be used the first time through the  function, so if
I give it a name, as in:

myfun(Param1, ...) -> something;
myfun(Param1, ....) ->

     myfun(value).

I get a warning that Param1 wasn't used.

If I do:

myfun(Param1, ...) -> something;
myfun(Param1, ....) ->

     Param1 = value,
     myfun(Param1).

I get the usual immutable error.

How do I do this?

_______________________________________________
erlang-questions mailing list
[hidden email]
http://erlang.org/mailman/listinfo/erlang-questions
Reply | Threaded
Open this post in threaded view
|

Re: Dummy question

PAILLEAU Eric
Hello,

either use '_' variable .

myfun(Param1, ...) -> something;
myfun(_, ....) ->

       myfun(value).

or directly the param you want to match

myfun(Param1, ...) -> something;
myfun(0, ....) ->

       myfun(value).


Le 02/03/2019 à 01:36, Donald Steven a écrit :
> myfun(Param1, ...) -> something;
> myfun(Param1, ....) ->
>
>      myfun(value).

_______________________________________________
erlang-questions mailing list
[hidden email]
http://erlang.org/mailman/listinfo/erlang-questions