ruby array or any other iteration return value or nil

原创文章,转载请注明来源并保留原文链接

a = [1,2,3,3,4]
a.detect {|n| n == 3}

其中的循环只执行3次

Leave a Reply

Your email address will not be published. Required fields are marked *