作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
0 -> "too big-6ren">
我正在阅读《七周内增加七种语言》一书的榆树章节。
作者在第 43 页描述了多行 if
通过以下方式:
x = 5
if | x < 0 -> "too small" \
| x > 0 -> "too big" \
| otherwise -> "just right"
SYNTAX PROBLEM
:
> if | x < 0 -> "too small" \
| | x > 0 -> "too big" \
| | otherwise -> "just right"
-- SYNTAX PROBLEM -------------------------------------------- repl-temp-000.elm
I ran into something unexpected when parsing your code!
3| if | x < 0 -> "too small"
^
I am looking for one of the following things:
an expression
whitespace
if
-
else
声明。是否可以创建多行语句,例如
最佳答案
多路if
Elm 0.16 中删除了语法。这是blog post discussing the change .
您可以使用 else if
和 else
实现您所追求的功能。
if x < 0 then
"too small"
else if x > 0 then
"too big"
else
"just right
关于elm - 条件 : How is the syntax for a multiline if statement in Elm?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41401074/
我是一名优秀的程序员,十分优秀!