问题描述:

case get(?Player_LoopTaskInfo) of
{TargetCnt, TaskStar, TaskExp} ->
ok;
_ ->
throw("not_found_loop_task_info")
end
在case语句中,这样写,编译时,会提示变量unsafe,解决编译器报错的方法有下面两个:
1、给unsafe的变量赋值
case get(?Player_LoopTaskInfo) of
{TargetCnt, TaskStar, TaskExp} ->
ok;
_ ->
TargetCnt=0,TaskStar=0,TaskExp=0,
throw("not_found_loop_task_info")
end

2、把case语句拆成函数

{TargetCnt, TaskStar, TaskExp} = valid_task_info(get(?Player_LoopTaskInfo))
valid_task_info({_, _, _} = Info) -> Info;
valid_task_info(_) -> throw("not_found_loop_task_info").
05-11 18:23