Created
October 5, 2011 17:30
-
-
Save julioterra/1265089 to your computer and use it in GitHub Desktop.
enumerable filter methods
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 = ["sparkfun", "adafruit", "digikey", "seed studio", "mouser", "jameco"] | |
| p array.find {|cur| cur =~ /di/} | |
| p array.find_all {|cur| cur =~ /di/} | |
| p array.select {|cur| cur =~ /di/} | |
| p array.reject {|cur| cur =~ /di/} | |
| p array.grep(/.?di./) {|cur| cur.upcase} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment