What does “! []” Elm code syntax in Todomvc mean

后端 未结 2 733
闹比i
闹比i 2020-12-29 01:08

Coming from react, I am learning to understand Elm.

In the Todomvc example code, there is the following code snippet:

-- How we update our Model on a         


        
相关标签:
2条回答
  • 2020-12-29 01:32

    Note that this syntax is going away in the next version of Elm (0.19) so don't get into the habit of using it ;-)

    You can use today, and with 0.19:

    update : Msg -> Model -> ( Model, Cmd Msg )
    update msg model =
      case msg of
        NoOp ->
          (model, Cmd.none)
    
    0 讨论(0)
  • 2020-12-29 01:33

    Update for Elm 0.19

    Elm 0.19 has removed the exclamation point operator. You must now construct the tuple manually, as in (model, Cmd.none).

    Original Answer for Elm 0.18

    The exclamation point in model ! [] is just a short-hand function for (model, Cmd.batch []), which is the type returned from typical update statements. It is defined here

    0 讨论(0)
提交回复
热议问题