Vala 中的静态枚举?

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

我有这个片段:

public class Item : Object, ContentItem {
    public static enum State {
        STOPPED,
        RUNNING,
        PAUSED
    }
    ...
}

我得到:

error: syntax error, expected `enum'
   24 |     public static enum State {
      |            ^~~~~~             

有没有办法获取类静态枚举?显然,为每个

Item
实例复制类似枚举之类的东西是没有意义的。

enums vala
1个回答
0
投票

您不需要 static 关键字。您可以将枚举移至其自己的范围内。

public enum State {
    STOPPED,
    RUNNING,
    PAUSED
}

public class Item : Object, ContentItem {
    ...
}
© www.soinside.com 2019 - 2024. All rights reserved.