2
nodeという型をノードのリストと共に定義しました。ユーザー定義型を配列に追加する
type node = {name: string; description: string}
nodes = [] : list(node)
Iは、新しいノードを作成しselectedNodeのに割り当て、配列ノードに追加createNewNode()
と呼ばれる関数を作成しました。
line 19: createNewNode() =
line 20: selectedNode = {name="" remoteFSRoot=""} : node
line 21: nodes = [nodes | selectedNode]
...
私はこれをコンパイルすると、私は次のエラーを取得する:
Error
File "node.opa", line 21, characters 10-32, (21:10-21:32 | 592-614)
Expression has type { hd: list(node); tl: node }/'c.a but is coerced into
list('a).
Types { name: string; description: string } and
{ hd: 'a; tl: list('a) }/{ nil } are not compatible
Hint:
One of the sum types may be missing the following cases of the
other:
{ nil }
{ hd tl }.
は、このコンパイルメッセージは何を意味していると私はそれをどのように修正するのですか?
うん、それは常に何かシンプルな:)です。助けてくれてありがとう! – rancidfishbreath
もしあなたが確かめたいのなら、次のようにすることもできます:List.add(elt、mylist)またはList.cons(elt、mylist) – Fred