Fastest way to find a String into an array of string

前端 未结 5 1081
鱼传尺愫
鱼传尺愫 2021-02-12 18:10

The script has to verify if one predefined IP is present in a big array of IPs. Currently I code that function like this (saying that \"ips\" is my array of IP and \"ip\" is the

5条回答
  •  时光说笑
    2021-02-12 18:28

    have you tried the Array#include? function?

    http://ruby-doc.org/core-1.9.3/Array.html#method-i-include-3F

    You can see from the source it does almost exactly the same thing, except natively.

提交回复
热议问题