Crystal有静态方法吗?

Mat*_*tte 2 static-methods module crystal-lang

是否可以像在Ruby中那样在模块中执行静态方法?

module Test
    self.def test
        puts "test"
    end
end
Test::test
Run Code Online (Sandbox Code Playgroud)

expecting token 'EOF', not 'end'如果调用在同一个文件中(如例子中所示),我得到一个if,expecting token 'CONST', not 'test'如果我将调用放在另一个文件中.

我做错了什么?Crystal中的模块中是否有静态方法?

RX1*_*X14 5

类方法的正确语法def self.test不是self.def test.类方法是使用Test.test而不是Test::test.