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.
有谁知道为什么下面的代码返回一个空数组?谢谢。
groovyc_deps = Buildr::Groovy::Groovyc.dependencies groovy_jar = groovyc_deps.grep /.*groovy.*\.jar/ p groovy_jar # => []
因为Groovyc.dependencies返回一个数组Artifact,而不是字符串。
Groovyc.dependencies
Artifact
试试下面的,
groovyc_deps = Buildr::Groovy::Groovyc.dependencies groovy_jar = groovyc_deps.select { |a| a.to_s =~ /.*groovy.*\.jar/ }
在匹配正则表达式之前将工件转换为字符串。