Rotareti
Rotareti

Reputation: 53963

What does the double colon ( :: ) mean in 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?

Upvotes: 4

Views: 1549

Answers (1)

Sidney
Sidney

Reputation: 4775

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

Upvotes: 10

Related Questions