前景提要
HDC调试需求开发(15万预算),能者速来!>>>
erl 编译之后报错,
我本意是:
showPerson/1 函数输出 用户信息,他的参数要么是 元祖 {Name, Age, Phone} 要么是 记录 -record (person, {name, age=0, phone=""}).
求指点,给个争取的实现方式。。。。
编译之后报错,信息如下:
[master●] » erl
Erlang/OTP 18 [erts-7.0] [source] [64-bit] [smp:8:8] [async-threads:10] [hipe] [kernel-poll:false]
Eshell V7.0 (abort with ^G)
1> c(tuples1).
tuples1.erl:20: illegal guard expression
error
2>
元代码如下 -module (tuples1). -export ([test/0, test1/0 ]). -record (person, {name, age=0, phone=""}). birthday({Name, Age, Phone}) -> {Name, Age+1, Phone}; birthday(P) -> #person{age=Age} = P, P#person{age=Age+1}. joe() -> {"Joe", 21, "999-999"}. showPerson(P) -> case P of {Name, Age, Phone} -> io:format("name:~p age:~p phone:~p~n", [Name, Age, Phone]); P1 when is_recode(P1, person) -> io:format("name:~p age:~p phone:~p~n", [P1#person.name, P1#person.age, P1#person.phone]) end. test() -> P = #person{name="leeyi", age=18, phone="13692177080"}, showPerson(birthday(P)), Tp = {P#person.name, P#person.age, P#person.phone}, showPerson(Tp), showPerson(joe()). test1() -> showPerson(birthday(joe())).