Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Assign a value in elm

Tags:

elm

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!

like image 524
Mr Giggles Avatar asked Nov 28 '17 09:11

Mr Giggles


1 Answers

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

Reset ->
  0
like image 81
Dogbert Avatar answered Nov 04 '22 09:11

Dogbert