In Ruby, how do I check that not only does an array contain elements of another array, but in that particular order?
correct_combination = [1, 2, 3, 4, 5] [1, 5, 8, 2, 3, 4, 5]. Function_name (correct_connection) # = & gt; False [8, 10, 1, 2, 3, 4, 5, 9]. Function_name (correct_complore) # = & gt; I tried to use included
, but it is used to check if [1,2,3] .include? (2)
is true or not.
You can use each_ cons method:
Arr = [1, 2, 3, 4, 5] [1, 5, 8, 2, 3, 4, 5] .each_cons (arr.size). Include? Arr
In this case it will work for any element.
Comments
Post a Comment