Last active
January 11, 2018 16:27
-
-
Save betogrun/49f3ec29d3561dcff53a83ee7e2eb706 to your computer and use it in GitHub Desktop.
Even or Odd
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
array = [0,1,2,3,4,5,6,7,8,9] | |
array.each_with_object({:odd => [], :even => []}) do |item, memo| | |
memo[item.odd? ? :odd : :even] << item | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Using group_by