该方法返回一个布尔值,表明一个字符串是否等于另一个字符串。如果字符串相等,则将返回true值,否则将返回false值。

equal - 语法

equal(str1,str2)
  • str1,str2   -  需要比较的2个字符串。

equal - 返回值

如果两个字符串相等,它将返回true值,否则将返回false值。

-module(helloLearnfk). 
-import(string,[equal/2]). 
-export([start/0]). 

start() -> 
   Str1="This is a string1", 
   Str2="This is a string2", 
   Status=equal(Str1,Str2), 
   io:fwrite("~p~n",[Status]).

当我们运行上述程序时,我们将得到以下输出。

false

参考链接

https://www.learnfk.com/erlang/erlang-equal.html