Skip to content

Instantly share code, notes, and snippets.

@13k
Created March 5, 2009 15:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save 13k/74382 to your computer and use it in GitHub Desktop.
Save 13k/74382 to your computer and use it in GitHub Desktop.
class Array
def slices(*args)
args.map do |arg|
case arg
when Range, Fixnum
self[arg]
else
raise ArgumentError, "Arguments for slices() must be either Fixnum or Range"
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment