榆树动作法中的管道符号
Pipe symbol in elm action method
update action model =
case action of
Delete id ->
{ model | tasks <- List.filter (\t -> t.id /= id) model.tasks }
我不明白这个语法,
{ model | .......... }
管道符号 |
在这里有什么作用?
花括号{}
是什么意思?动作 Delete
return 有任何价值吗?
此代码取自 elm 的 Todo tutorial。
这是记录更新语法:http://elm-lang.org/docs/records#updating-records
{ model | tasks <- value }
returns model
记录 tasks
字段设置为新值。
update action model =
case action of
Delete id ->
{ model | tasks <- List.filter (\t -> t.id /= id) model.tasks }
我不明白这个语法,
{ model | .......... }
管道符号 |
在这里有什么作用?
花括号{}
是什么意思?动作 Delete
return 有任何价值吗?
此代码取自 elm 的 Todo tutorial。
这是记录更新语法:http://elm-lang.org/docs/records#updating-records
{ model | tasks <- value }
returns model
记录 tasks
字段设置为新值。