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.
无论大小写如何,如何确定字符串是否以另一个字符串结尾?
filename.end_with?(*%w(.ext1 .e2 .extension))
此示例仅在 case 也匹配时才匹配。不分大小写如何匹配?
将文件名更改为小写并与小写扩展名进行比较。
filename.downcase.end_with?(*%w(.ext1 .e2 .extension))
'MAIN.RB'.downcase.end_with?(*%w(.ruby .rb)) # => true