在榆树中,我有一个类似的清单:
[ Just a, Nothing, Just b]
Run Code Online (Sandbox Code Playgroud)
我想从中提取:
[a, b]
Run Code Online (Sandbox Code Playgroud)
除非我错了,否则使用List.map和模式匹配是不允许的,因为当列表中的值为Nothing时我什么也不会返回。我怎样才能做到这一点?
使用elm-css,我想在before伪元素中指定content属性。
我翻译了
div.boxclose{
float:right;
margin-top:-30px;
margin-right:-30px;
cursor:pointer;
color: #fff;
border: 1px solid #AEAEAE;
border-radius: 30px;
background: #605F61;
font-size: 31px;
font-weight: bold;
display: inline-block;
line-height: 0px;
padding: 11px 3px;
}
.boxclose:before {
content: "×";
}
Run Code Online (Sandbox Code Playgroud)
与
div
[ css
[ float right
, marginTop (px -30)
, marginRight (px -30)
, cursor pointer
, color white
, border3 (px 1) solid darkGrey2
, borderRadius (px 30)
, backgroundColor lightGrey
, fontSize (px 31)
, fontWeight bold
, display inlineBlock …Run Code Online (Sandbox Code Playgroud) 我有一个更新功能,如:
update : Msg -> Model -> (Model, Cmd Msg)
update msg model =
case msg of
NewImages (Ok images) ->
({model|images = images}, Cmd.none)
NewImages (Err error) ->
myFunction model
NewUsers (Ok users) ->
({model|users = users}, Cmd.none)
NewUsers (Err error) ->
myFunction model
[...]
Run Code Online (Sandbox Code Playgroud)
和myFunction每次我得到HTTP.Error时我想调用的函数.
显然,_不能用来匹配像中的模式的开头
update : Msg -> Model -> (Model, Cmd Msg)
update msg model =
case msg of
NewImages (Ok images) ->
({model|images = images}, Cmd.none)
NewUsers (Ok users) -> …Run Code Online (Sandbox Code Playgroud)