Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
# Remove adjacent duplicates in an array.
# @param [Array] a_list the array to de-dup
# @return [Array] the processed list of items
# @note Created to help display a user's log entries.
def de_dup(a_list)
a_list.reduce([]) do |new_list, elem|
new_list + (new_list.last.eql?(elem) ? [] : [elem])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment