Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #Write a custom method that emulates the .uniq method on an Array
- #Must return brand new array
- #Bonus have the new array be sorted
- num = [1, 2, 4, 4, 2, 3, 3, 6, 9, 1, 10, 4, 5, 7, 6]
- def custom_uniq(arry)
- new_arry = []
- arry.each { |elm| new_arry << (elm) unless new_arry.include?(elm) }
- new_arry.sort
- end
- p custom_uniq(num)
Add Comment
Please, Sign In to add comment