Process.register
You're seeing just the function
register
, go back to Process module for more information.
Specs
Registers the given pid_or_port
under the given name
.
name
must be an atom and can then be used instead of the
PID/port identifier when sending messages with Kernel.send/2
.
register/2
will fail with ArgumentError
in any of the following cases:
- the PID/Port is not existing locally and alive
- the name is already registered
- the
pid_or_port
is already registered under a differentname
The following names are reserved and cannot be assigned to processes nor ports:
nil
false
true
:undefined
Examples
Process.register(self(), :test)
#=> true
send(:test, :hello)
#=> :hello
send(:wrong_name, :hello)
** (ArgumentError) argument error