jeudi 25 mars 2021

When do we use nested modules and nested classes in Ruby?

I came across two files which had a structure like this. What are some practical examples in which I will create File A to execute some code, and similarly when would the structure of File B be more useful ? I take it that the answer lies somewhere in reusability and name spacing ?, but I am not able to give myself a clear answer as to what the difference between these two are.

file_a.rb

module A
  module B
   // Code runs here
  end
end

file_b.rb

module A
  class B
   // Code runs here
  end
end

Aucun commentaire:

Enregistrer un commentaire