Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我想找到名称与字符串匹配的所有 ruby 类(忽略大小写)。这意味着该字符串应该是类名的子字符串。 因此,当您搜索“stri”时,您应该得到类String(以及其他类)作为结果。
String
您知道一种方便且不太低效的方法吗?
ObjectSpace.each_object(Class) .select{|klass| klass.name.downcase.include?("stri".downcase)} # => [ String, RubyToken::TkDXSTRING, RubyToken::TkDSTRING, RubyToken::TkXSTRING, RubyToken::TkSTRING ]