Skip to content

Instantly share code, notes, and snippets.

@julioterra
Created October 5, 2011 17:21
Show Gist options
  • Select an option

  • Save julioterra/1265069 to your computer and use it in GitHub Desktop.

Select an option

Save julioterra/1265069 to your computer and use it in GitHub Desktop.
enumerable boolean methods
array = ["sparkfun", "adafruit", "digikey", "seed studio", "mouser", "jameco"]
p array.all? {|cur| cur =~ /a/}
p array.any? {|cur| cur =~ / /}
p array.one? {|cur| cur =~ /m/}
p array.none? {|cur| cur =~ /z/}
p array.include?("sparkfun")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment