'Conditionally change record in update

I would like to have some logic worked upon the Msg and, depending on the result, update the view in a different ways.

I'm flipping some cards, and I want to test two of the selected ones. Then, accept them as a pair or discard and try again.

update : Msg -> Model -> Model
update msg model =
    case msg of
        ClickedCard data ->
            { model
                | activeCard = data.id
                , (if List.lenght selectedCards < 2 then
                      selectedCards = data.id :: model.selectedCards
                  else if (List.take 1 model.selectedCards) == (List.drop 1 model.selectedCards) then
                           completedPairs = ( List.take 1 model.selectedCards , List.drop 1 model.selectedCards ):: model.completedPairs
                          else
                              selectedCards = List.drop 2 model.selectedCards)
            }

        _ ->
            model

But, seems like I can't insert the logic there. Where should I put it, instead?

-- PROBLEM IN RECORD ------------------------------------------ src/Flipping.elm

I am partway through parsing a record, but I got stuck here:

126|             { model
127|                 | activeCard = data.id
128|                 , (if List.lenght selectedCards < 2 then
                       ^
I was expecting to see another record field defined next, so I am looking for a
name like userName or plantHeight.
elm


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source