Erlang创建记录错误

时间:2015-01-10 18:40:47

标签: erlang

我正在学习Erlang。我正在测试记录,当我尝试运行我的函数创建记录时,我收到此异常错误:** exception error: no function clause matching

控制台:

123> hello:helloRecords().
** exception error: no function clause matching 
                    hello:createCar("BL 45 HK","Skoda octavia","White") (hello.erl, line 21)
     in function  hello:helloRecords/0 (hello.erl, line 28)

代码:

-module(hello).
-author("Eddy").

-record(car, {evc, type, color}).
-record(person, {name, phone, addres, rc}).
-record(driver, {rc, evc}).


%% API
-export([helloIF/1, helloCase/1, helloResult/1, helloList/0, map/2, filter/2, helloListCaA/0, createCar/3, createPerson/4, createDriver/2, helloRecords/0]).


createCar(p_evc, p_type, p_color) -> _car = #car{evc = p_evc, type = p_type, color = p_color}, _car
  .
createPerson(p_name, p_phone, p_addres, p_rc) -> _person= #person{name = p_name, phone = p_phone, addres = p_addres, rc = p_rc}, _person
  .
createDriver(p_evc, p_rc) -> _driver = #driver{rc = p_rc, evc = p_evc}, _driver
  .

helloRecords() -> _car = hello:createCar("BL 45 HK", "Skoda octavia", "White"),
                  _person = hello:createPerson("Eduard B.","+421 917 111 11","Krížna XX, 811XX Bratislava1", 8XXXXXXX5),
                  _driver = hello:createDriver(_car#car.evc, _person#person.rc),
                  io:fwrite(_person#person.name),
                  io:fwrite(" Je vodič auta:"),
                  io:fwrite(_car#car.type),
                  io:fwrite(" farba:"),
                  io:fwrite(_car#car.color),io:fwrite("\n")
  .

1 个答案:

答案 0 :(得分:3)

createCar(p_evc, p_type, p_color) -> ...变量必须以大写字母作为第一个字符。该子句期望三个原子p_evcp_typep_color不是用作参数的值,因此no function clause matching错误。