Case-insensitive Array#include?

后端 未结 6 1039
小蘑菇
小蘑菇 2020-12-13 12:35

I want to know what\'s the best way to make the String.include? methods ignore case. Currently I\'m doing the following. Any suggestions? Thanks!



        
6条回答
  •  一整个雨季
    2020-12-13 13:06

    my_array.map!{|c| c.downcase.strip}

    where map! changes my_array, map instead returns a new array.

提交回复
热议问题