I am working on a code base that has many modules nested 4 or 5 deep. Right now, this results in our code being heavily indented from the beginning.
Is there an acceptable way of putting multiple module declarations on the same line?
For example,
module A
module B
#do stuff
end
end
Is there a way to make it something like this?
module A::B
#do stuff
end
Though the previous block doesn’t work, I was able to get this next one to work, however I am not sure if this is considered acceptable code construction.
module A module B
#do stuff
end end
I think you’ve answered it yourself – your third segment looks pretty bad to my eye.
But, more to the point, if you did write
module A::Bandmodule Ahad never been defined before, you would be implicitly defining an (empty)module A, which doesn’t seem very useful. And, once you’ve definedmodule Aonce, you’re welcome to writemodule A::Bto definemodule B. So it seems actively good to me that you can’t use your second example.