这是一个非常菜鸟的问题,很抱歉,但我在互联网上的搜索无法找到答案。我有以下代码:
-- MODEL
type alias Model = Int
model : Model
model =
0
-- UPDATE
type Msg = Increment | Decrement | Reset
update : Msg -> Model -> Model
update msg model =
case msg of
Increment ->
model + 1
Decrement ->
model - 1
Reset ->
model = 0
我正在尝试实现将模型值设置为 0 的重置。但我收到一个编译错误:
The = operator is reserved for defining variables. Maybe you want == instead? Or maybe you are defining a variable, but there is whitespace before it?
请帮忙!
最佳答案
您只需要在那里写入模型的新值。在这种情况下,这只是 0
:
Reset ->
0
关于elm - 在 elm 中赋值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47528432/