I need to merge consecutive repeating elements in an array, such that
[1, 2, 2, 3, 1]
becomes
[1, 2, 3, 1]
does !uniq not work for what you are doing?
!uniq
http://ruby-doc.org/docs/ProgrammingRuby/html/ref_c_array.html