Erlang - is_pid



此方法用於確定程序 ID 是否存在。

語法

Is_pid(processid)

引數

  • processid − 這是需要檢查是否存在程序 ID。

返回值

如果程序 ID 存在則返回 true,否則返回 false。

例如

-module(helloworld). 
-export([start/0, call/2]). 

call(Arg1, Arg2) -> 
   io:format("~p ~p~n", [Arg1, Arg2]). 

start() -> 
   Pid = spawn(?MODULE, call, ["hello", "process"]), 
   io:fwrite("~p",[is_pid(Pid)]).

輸出

當我們執行以上程式時,我們將得到以下結果。

true"hello" "process"
erlang_processes.htm
廣告

© . All rights reserved.