2016-12-30 8 views
1

私は本のエルムの章を読んでいます7つのより多くの言語を7週間で。 43ページ は、著者は次のように複数行ifを説明します条件:Elmの複数行if文の構文はどのようになっていますか?

x = 5 

if | x < 0 -> "too small" \ 
    | x > 0 -> "too big" \ 
    | otherwise -> "just right" 

しかし、エルム-REPLは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の使用方法を発見しました。本の中で説明されている のような複数行の文を作成することは可能ですか?

答えて

8

マルチウェイifの構文がElm 0.16で削除されました。ここにはblog post discussing the changeがあります。

else ifelseを使用して、後で機能させることができます。

if x < 0 then 
    "too small" 
else if x > 0 then 
    "too big" 
else 
    "just right 
関連する問題