Hi,
I’m not sure how to use the syntax for if and else inside the “let” scope in Elm.
What doesn’t work is the below code.
backgroundRect : Int -> Svg msg
backgroundRect v =
let
color = "red"
m = modBy 2 v
if m == 0 then
color = "green"
else
color = "blue"
in
Svg.rect
[ width "100%"
, height "100%"
, fill color
]
[]
As a work around I’m doing this, which is ugly. Any inputs on how to use “if and else inside the let and in block?”
backgroundRect : Int -> Svg msg
backgroundRect v =
let
color = "red"
m = modBy 2 v
in
if m == 0 then
Svg.rect
[ width "100%"
, height "100%"
, fill "Green"
]
[]
else
Svg.rect
[ width "100%"
, height "100%"
, fill "red"
]
[]
Best,
SantMan