Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does the double colon ( :: ) mean in Elm?

Tags:

syntax

elm

I'm new to Elm and I just came across this:

update : Msg -> Model -> (Model, Cmd Msg)
update msg model =
  case msg of
    UrlChange location ->
      ( { model | history = location :: model.history }
      , Cmd.none
)

Could someone tell me what the double colon does in line 5?

like image 542
Rotareti Avatar asked Jan 29 '23 13:01

Rotareti


1 Answers

That's the cons operator. It adds an item to the front of a list.

1 :: [2,3] == [1,2,3]
1 :: [] == [1]

Documentation:

https://package.elm-lang.org/packages/elm/core/latest/List#::

like image 153
Sidney Avatar answered Feb 20 '23 04:02

Sidney