如何更新列表中的項目?如何更新列表中的項目並維護其索引?
我試過如下:
setFeaturedLink links link =
let
dictionary =
Dict.fromList links
result =
Dict.filter (\k v -> v.title == link.title) dictionary |> Dict.toList |> List.head
index =
case result of
Just kv ->
let
(i, _) =
kv
in
i
Nothing ->
-1
in
if not <| index == -1 then
Dict.update index (Just { link | isFeatured = isFeatured }) dictionary |> Dict.values
else
[]
的第二個參數的功能
update
導致不匹配。59 | Dict.update指數(只是{鏈接| isFeatured = isFeatured})字典 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^功能
update
期待 第二個參數是:Maybe { contentType : ContentType , profile : Profile , title : Title , topics : List Topic , url : Url , isFeatured : Bool } -> Maybe { contentType : ContentType , isFeatured : Bool , profile : Profile , title : Title , topics : List Topic , url : Url }
但它是:
Maybe { contentType : ContentType , isFeatured : Bool , profile : Profile , title : Title , topics : List Topic , url : Url }
提示:它看起來像一個函數需要1級以上的說法。
有沒有一個簡單的例子可以更新列表中的任意項目?
我很尷尬...... –
這很好:) –