Skip to content

Instantly share code, notes, and snippets.

@MichaelCPell
Created March 24, 2015 23:59
Show Gist options
  • Save MichaelCPell/031f9e8231b93e64d3c9 to your computer and use it in GitHub Desktop.
Save MichaelCPell/031f9e8231b93e64d3c9 to your computer and use it in GitHub Desktop.
#sorting
def sort_by_length(array)
array.sort { |x, y| x.length <=> y.length }
end
def filter(array)
array.select { |v| v > 5 }
end
#mapping
def add_two(array)
array.map do |x|
"#{x} + 2 = #{x+2}"
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment