记录

语法:

  -record(Name, {

          Key1 = Default1,

          Key2 = Default2,

                  ...

          Key3,

          ...

          }).

  Name记录名,Key1,Key2字段名

创建记录

  -record(state, {io, client})

  State = #state{}.

提取字段值

  1 模式匹配

   #state{io = IO} = State.

  2 点语法

   IO = State#state.io

 

-record(task,{name,content}).

#record.name 返回name 的索引,2

State#record.name 返回State变量中name字段的值

 

posted @ 2013-09-04 11:52  wangjunshusheng  阅读(135)  评论(0)    收藏  举报