我有一个函数可以将 Maybe Block 渲染为 Svg 矩形
type alias Block = {x:Int, y:Int}
type alias Prey = Maybe Block
renderPrey : Prey -> Svg Msg
renderPrey prey =
case prey of
Maybe.Just block -> --Svg rect returns Svg msg
Nothing -> -- how do I return something like Svg.none?
我看到没有 Svg.none http://package.elm-lang.org/packages/elm-lang/svg/2.0.0/Svg
我的解决方案是更改签名
renderPrey : Prey -> List(Svg Msg)
renderPrey prey =
case prey of
Maybe.Just block -> [--Svg rect returns Svg msg]
Nothing -> []
最佳答案
我使用Svg.text ""
。到目前为止,我还没有遇到任何问题,但我还没有编写很多 SVG。
关于elm - Elm 中 Maybe a -> Svg Msg 类型的函数中没有 Nothing 时返回什么,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50195574/