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
Post a Comment