Fastest way to find a String into an array of string

前端 未结 5 1680
被撕碎了的回忆
被撕碎了的回忆 2021-02-12 18:18

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:24

    ips = ['10.10.10.10','10.10.10.11','10.10.10.12']
    
    ip = '10.10.10.10'
    ips.include?(ip) => true
    
    ip = '10.10.10.13'
    ips.include?(ip) => false
    

    check Documentaion here

提交回复
热议问题