Skip to content

Static members #2513

@xushiwei

Description

@xushiwei

XGo static members (including static methods, see #1847):

const T.name = ... // static constant

var T.name V = ... // static variable

func T.Method(arg1 T1, arg2 T2, ..., argN TN) (ret1 R1, ret2 R2, ..., retM RM) // static method

XGo classfile T's static members:

const name = ... // constant is always "static"

var T.name V = ...
var .name V = ...

func T.Method(arg1 T1, arg2 T2, ..., argN TN) (ret1 R1, ret2 R2, ..., retM RM)
func .Method(arg1 T1, arg2 T2, ..., argN TN) (ret1 R1, ret2 R2, ..., retM RM)

Refer static members:

T.method(arg1, arg2, ..., argN) // call static method
T.name // access static variable/constatnt

If accessing from within this classfile, or accessing the corresponding project class from a work class, it can be further simplified:

method(arg1, arg2, ..., argN) // call static method
name // access static variable/constatnt

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions