julia - 如何在 Julia 中使模块中的自定义枚举类型可用
问题描述
我正在尝试在模块中定义枚举类型,以便可以在所有函数中使用它。导出模块时,只能获取枚举类型,但无法识别枚举类型的元素。
module testaux
greet() = print("Hello World!")
@enum Stortype colMajor rowMajor
@enum Sorttype ascend descend nosort
end # module
成功导入 testaux 后,我可以调用 greet() 并识别 Stortype。但是我没有使用 Stortype 通过以下定义来限制我的函数参数:
function t(a::Stortype)
println(a)
end
t(colMajor)
会抱怨 colMajor 未定义。
解决方案
推荐阅读
- kubernetes - 如何手动检查 k8s 部署是否通过/失败?
- mysql - 节点 Lambda:MySQL 查询从不运行
- python - 在 Python 中输出输入的每个字符的 ASCII 值的总和
- json.net - Newtonsoft JsonConvert DeserializeObject 不能忽略实体错误的默认值?
- python - 如何拆分 Python 代码的输出?
- angular - 显示日期时间并添加分钟
- reactjs - 在一个 post 请求中发送图像文件和数据
- python - 如何使用sklearn的矩阵分解来预测新用户的推荐分数
- visual-studio-code - VS 代码不突出语法错误
- c# - 更改页面和显示模式时Android上的Webview显示问题(纵向->横向)