I have a sorted array of elements (unique and not consecutive):
array= ["AAA", "BBB", "CCC", "DDD", "EEE"]
I defined a range of elements:
range_1 = ("CC" .. "DD")
range_2 = ("B" .. "E")
The range of elements are just strings which refers to an array elements but only if starts_with? is true for these elements. Example:
"C", "CC" and "CCC" in range - fits to "CCC" in array
"D", "DD" and "DDD" in range - fits to "DDD" in array
The desired results for range_1 and range_2 would be like this:
result_1 = ["CCC", "DDD"]
result_2 = ["BBB", "CCC", "DDD", "EEE"]
How to implement this in Ruby?
start_with?already. So, where's your code?start_with?from here ruby-doc.org/core-2.0.0/String.html#method-i-start_with-3F