Is there an inverse 'member?' method in ruby?

前端 未结 5 1023
礼貌的吻别
礼貌的吻别 2020-11-30 12:55

I often find myself checking if some value belongs to some set. As I understand, people normally use Enumerable#member? for this.

end_index = [\         


        
5条回答
  •  天命终不由人
    2020-11-30 13:25

    In your specific case there's end_with?, which takes multiple arguments.

    "Hello.".end_with?(',', '.') #=> true
    

提交回复
热议问题