Erlang - Write a template that binds the variable to the second element in this tuple {<0.206.0>, {rect, 10, 30}}

How to write a template that binds a variable to the second element in this set {<0.206.0>, {rect, 10, 30}}?

those. "here instead of a pattern", which leads to the Form having the value {rect, 10, 30}. Pattern = {<0.206.0>, {rect, 10, 30}}

This is the part <0.206.0> that confuses me.

+3
source share
3 answers

Easier than that ...

{_, Shape} = {<0.206.0>, {rect, 10, 30}}.

However, you cannot create a process identifier from a literal, so the syntax above is incorrect, but try this in REPL ...

1> {_, Shape} = {self(), {rect, 10, 30}}.
{<0.31.0>,{rect,10,30}}
2> Shape.
{rect,10,30}
+8
source

<0.206.0> PID. , .

, dsmith, , :

Shape = element(2, {<0.206.0>, {rect, 10, 30}}).
+4

For your additional help, you can use the function pid/0to "create" a specific Pid:

1> Pid = pid(0,206,0).
<0.206.0>
2> {Pid, Shape} = {Pid, {rect, 10, 30}}.
{<0.206.0>,{rect,10,30}}
+3
source

Source: https://habr.com/ru/post/1751308/


All Articles