如何在Julia中初始化一个抽象(abstract)?

huangapple go评论90阅读模式
英文:

How to initialise an abstract in Julia?

问题

Julia> abstract Shape
ERROR: 语法: 表达式结束后的额外标记 "Shape"
Stacktrace:
[1] top-level scope at REPL[64]:0

只想创建一个抽象,但即使使用帮助,它也会显示以下内容>
是否有任何替代方法?

help?> abstract
search: AbstractSet abstract type AbstractChar AbstractDict AbstractFloat

找不到抽象
也许你想要的是 struct 或 AbstractSet
没有找到文档。

绑定 abstract 不存在。

英文:
Julia> abstract Shape
ERROR: syntax: extra token "Shape" after end of expression
Stacktrace:
 [1] top-level scope at REPL[64]:0

Just wanted to create an abstract but it says following even when I use help?>
Is there any alternate to this?

help?> abstract
search: AbstractSet abstract type AbstractChar AbstractDict AbstractFloat

Couldn't find abstract
Perhaps you meant struct or AbstractSet
  No documentation found.

  Binding abstract does not exist.

答案1

得分: 4

正确的语法是 abstract type Shape end

您可以在 REPL 帮助模式下通过完整的关键字查找文档:
help?> abstract type

关于该关键字的在线文档以及关于类型的更一般性文档也可供参考。

英文:

The correct syntax is abstract type Shape end.

You can find the docs in the REPL help mode with the full keyword:

help?> abstract type

There is online documentation on the keyword and more general documentation on types.

huangapple
  • 本文由 发表于 2020年1月7日 02:37:01
  • 转载请务必保留本文链接:https://go.coder-hub.com/59617240.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定