目录

equal

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

语法 (Syntax)

equal(str1,str2)

参数 (Parameters)

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

返回值 (Return Value)

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

例如 (For example)

-module(helloworld). 
-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]).

输出 (Output)

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

false
↑回到顶部↑
WIKI教程 @2018