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?
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#::
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With