考虑下面的示例代码:| |是怎么回事?在Elm读的符号?
-- Update the fields of a record. (It must have the fields already.)
{ person |
name = "George" }
-- Update multiple fields at once, using the current values.
{ particle |
position = particle.position + particle.velocity,
velocity = particle.velocity + particle.acceleration }
一个应该如何在这个例子中阅读|
,并在榆树一般?我很熟悉它在set-builder表示法中是“where”/“such that”,而在Haskell的列表解析中它有一个非常类似的目的,例如,
[ x*2 | x <- [1..10] ]
是逻辑上等同于
(当然我也熟悉它作为一元 “或” 运营商C使用类语言)
怎么样像type Msg = Increment | Decrement
?
或者,在这个例子中讨论Union Types时:
type Boolean
= T
| F
| Not Boolean
| And Boolean Boolean
| Or Boolean Boolean
我不知道它是如何官方,但我总是说“在哪里”。例如,名字等于乔治的人。 – Joe
@Joe但是'type Msg = Increment |在https://指南中减量。elm-lang.org? –
上下文很重要。在那种情况下,我会说“或”。类型Msg是递增或递减。不知道为什么这没有发表第一条评论。 – Joe