1
我想写这是否文件名匹配,扩展并不重要
def search_for_filenames(dir, name)
# goes to the directory and returns a list of files that match
# the given name, regardless of extension
end
因此,举例来说,如果名字是test
,我的目录包含下列
test.png
test.txt
something_else.dat
该方法将一种方法返回一个包含前两个文件名的数组
我该怎么写这个方法?
嗯我可能会探索其他方法来做到这一点,如果我有时间但现在我用glob。 – MxyL 2012-07-28 20:57:32
glob应该总是更快,因为它全部用C完成,无论我的方式是否有更多的ruby转换为C,但我只是猜测。不要认真对待 – 2012-07-28 21:17:58