无法将字典添加到Repl

时间:2018-09-16 21:59:38

标签: elm

如何将其添加到带有换行符的repl中?

import Dict
fruit = Dict.fromList \
    [ \
      ((0,0), 'Apple') \
      ,((0,1), ' ') \      
    ]

错误

> fruit = Dict.fromList \
|     [ \
|       ((0,0), 'Apple') \
|       ,((0,1), ' ') \      
-- SYNTAX PROBLEM -------------------------------------------- repl-temp-000.elm

The = operator is reserved for defining variables. Maybe you want == instead? Or
maybe you are defining a variable, but there is whitespace before it?

5|   fruit = Dict.fromList 

是否不可能在要添加行返回的列表的repl中执行此操作?

1 个答案:

答案 0 :(得分:2)

不是我所知道的语言,但以为我会看一下。看来可行:

import Dict
fruit = Dict.fromList \
    [ \
      ((0,0), "Apple") \
      ,((0,1), " ") \
    ]

,((0,1), ' ') \之后,您似乎有一些尾随空格

我还需要双引号,https://elmprogramming.com/string.html似乎支持这种说法

通过最小限度的测试-如果包含尾随空格,则其行为类似于您的示例:

import Dict
fruit = Dict.fromList [ \