Is it possible to do static methods in modules as in Ruby ?
module Test
self.def test
puts "test"
end
end
Test::test
I get a expecting token 'EOF', not 'end'
if the call is in the same file ( as shown in the exemple ) and a expecting token 'CONST', not 'test'
if I place the call in a different file.
What am I doig wrong ? Is there static methods in modules in Crystal ?
The correct syntax for class methods is def self.test
, not self.def test
. Class methods are called using Test.test
, not Test::test
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With