How to update nested Records?
type alias Movie =
{ title : String
, rating : Int
}
type alias Model =
{ currentMovie : Movie
}
rate : Int -> Model -> Model
rate newRating model =
{ model
| currentMovie =
--{ model.currentMovie | rating = newRating }
Debug.todo "the line above does not compile"
}type alias Movie =
{ title : String
, rating : Int
}
type alias Model =
{ currentMovie : Movie
}
rate : Int -> Model -> Model
rate newRating ({currentMovie} as model) =
{ model
| currentMovie =
{currentMovie | rating = newRating }
}Question
Answer
Further reading
Last updated