如何更新列表中的项目?如何更新列表中的项目并维护其索引?
我试过如下:
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级以上的说法。
有没有一个简单的例子可以更新列表中的任意项目?
我很尴尬...... –
这很好:) –