Created
May 10, 2012 22:34
-
-
Save ianbishop/2656316 to your computer and use it in GitHub Desktop.
Symbol#to_proc map-reduce
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
| # Get total sum of the sizes of each word | |
| words = "Hello World, how are you today?".split(/\s/) | |
| words.map(&:size).inject(&:+) | |
| # => 26 | |
| # Validate numerous fields | |
| fields = ["foo", "bar", "tomato", "tomatoes", nil] | |
| valid = !fields.map(&:nil?).inject(&:|) | |
| # => false |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment