无法将字典添加到Repl

问题描述 投票:0回答:1

如何使用换行符将其添加到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 

是否只能在列表中使用要添加行返回的列表执行此操作?

elm
1个回答
2
投票

不是我认识的语言,但我想我会看看。这似乎有效:

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

你似乎在,((0,1), ' ') \之后有一些尾随的空白

另外,我需要双引号,这似乎是由https://elmprogramming.com/string.html支持的

通过最小化测试 - 如果包含尾随空格,则此行为与您的示例相似:

import Dict
fruit = Dict.fromList [ \ 
© www.soinside.com 2019 - 2024. All rights reserved.