6 ms·
Not sure what you mean. You can do… module Foo extend self def bar “Bar!” end end Foo.bar #=> “Bar!” And you can incl
by transfire 4y ago
Not sure what you mean.
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.
- TylerE 4y agoIn python you can ‘from foo import bar, buzz’ and get JUST those two functions, without having to prefix them or clobbering your namespace. 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
- transfire 4y agoI see. Yeah because of this Ruby kind of pressures thoughtful coders into small modules. Heck, I created Ruby Facets and it’s basically one method per file!