Created
December 18, 2012 18:00
-
-
Save xorrbit/4330384 to your computer and use it in GitHub Desktop.
Array range set thing
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
class Array | |
def with(range) | |
range.each do |i| | |
self.push i if not self.include? i | |
end | |
self | |
end | |
def then(range) | |
self.with(range) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
[].with('a'..'z').then('A'..'Z').then('0'..'9').then(' '..'~').then(0..255)
Gives us the set of all 256 characters, ordered by lowercase first, then uppercase, then numbers, then symbols, then the rest.