Enumerable Method - Partition
Nichole Shelton
November 22, 2014
Everyone in the BeyHive stand up! The Rubyists made a method just for us! I kid, but when I started researching which enumerable method I was going to use and I saw the partition method, I won't lie, I did dance in my chair
I love that song. But I digress. The partition method is pretty sweet. By defintion partition returns two arrays, the first containing the elements of enumumerator for which the block evaluates to true, the second containing the rest. Let's check out an example shall we?
Let's say you have an array and you're looking for all values that have a length of 3 or more. Below you'll find the code and the output
['happy', "birthday", "to","me"].partition {|s| s.length > 3}
=> [["happy", "birthday"], ["to", "me"]]
Hope you find this useful!

