Skip to content

Instantly share code, notes, and snippets.

@xorrbit
Created December 18, 2012 18:00
Show Gist options
  • Save xorrbit/4330384 to your computer and use it in GitHub Desktop.
Save xorrbit/4330384 to your computer and use it in GitHub Desktop.
Array range set thing
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
@xorrbit
Copy link
Author

xorrbit commented Dec 18, 2012

[].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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment