Skip to content

Instantly share code, notes, and snippets.

@selman
Created October 26, 2010 23:01
Show Gist options
  • Save selman/648040 to your computer and use it in GitHub Desktop.
Save selman/648040 to your computer and use it in GitHub Desktop.
class List
attr_reader :list
def initialize *args
args.each do |a|
if a.kind_of? Range
@list = parse(args, args.index(a))
end
end
end
def parse args, index
r = args[index]
Array.new(r.max) do |i|
x = args.dup
x[index] = i
x
end
end
end
a = List.new (1..10), 2, 3, 4
puts a.list.inspect
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment