闪烁意想不到的结构

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

我对 Gleam 100% 陌生,并尝试了我找到的一个简单的结构示例。

// src/first.gleam

pub struct Cat {
  name: String
  is_cute: Bool
}

pub fn main() {
  Cat(name: "Nubi", is_cute: True)
}

但是,我收到编译错误:

% gleam run
error: Syntax error
  ┌─ C:\Users\Sven\programming\Gleam\first\src\first.gleam:3:1
  │
3 │ pub struct Cat {
  │ ^^^ I was not expecting this

Expected one of:
An import, const, type, if block, or function.

这个问题有什么解决办法吗?

版本输出:

% gleam --version gleam 1.0.0 

compiler-errors gleam
1个回答
1
投票

编译器好像给出了提示:

Expected one of: An import, const, type, if block, or function.

pub type Cat {
  Cat(name: String, is_cute: Bool)
}
© www.soinside.com 2019 - 2024. All rights reserved.