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

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

javascript - firefox memory leak -

Trying to import CSV file to a SQL Server database using asp.net and c# - can't find what I'm missing -