gpt4 book ai didi

elm - 在 elm 中赋值

转载 作者:行者123 更新时间:2023-12-04 03:00:26 25 4
gpt4 key购买 nike

这是一个非常菜鸟的问题,很抱歉,但我在互联网上的搜索无法找到答案。我有以下代码:

-- 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/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com