16

This is a really noob question, i'm sorry but my search on the internet can't find the answer. I have the following code:

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

I am trying to implement the reset that sets the model value to 0. But i'm getting a compilation error:

The = operator is reserved for defining variables. Maybe you want == instead? Or maybe you are defining a variable, but there is whitespace before it?

Please help!

Mr Giggles
  • 2,483
  • 3
  • 22
  • 35

1 Answers1

29

You only need to write the model's new value there. In this case, that'll be just 0:

Reset ->
  0
Dogbert
  • 212,659
  • 41
  • 396
  • 397