enumerate - Ruby .detect alternative -


i looking alternative solve following issue:

with .detect if looking stringvalue , value given 132stringvalue, still return true. need alternative matching beginning of string. suggestions aside regex?

[1] pry(main)> %w[foo 456foo bar 123bar].detect {|e| e.to_i > 0} => "456foo" [2] pry(main)> %w[foo 456foo bar 123bar].detect {|e| e.start_with?('123')}                    => "123bar" 

Comments

Popular posts from this blog

php - cannot display multiple markers in google maps v3 from traceroute result -

c# - DetailsView in ASP.Net - How to add another column on the side/add a control in each row? -

javascript - firefox memory leak -