crystal-lang : how to fill an array with all modules defined in files in a specific package of the project?
问题 All in the question, I would like to know if it's possible to do something like this in Crystal (pseudo-code) : modules = Array(Module).new foreach (file in specific_package) do if (file.is_a(crystal_module) do modules.push(file.module) end end 回答1: Crystal doesn't have packages but modules. If you want to get all modules in a file you can try this: require "compiler/crystal/syntax" Modules = [] of String class ModuleVisitor < Crystal::Visitor def visit(node : Crystal::ModuleDef) Modules <<