by no_wizard · 4y ago · 0 comments
You can do…
module Foo
extend self
def bar
“Bar!”
end
end
Foo.bar #=> “Bar!”
And you can include that module in other modules. No classes required.This really nice when the one function you need is giantlib.helpers.foobar.convert_baz_to_qux - it’s both less bytes (especially if you are calling it a lot) and more importantly to the next reader of the code it means that c_b_to_q is the only thing you’re using in giantlib
I tend to go with static methods on modules.