Skip to content

Instantly share code, notes, and snippets.

@stevenheidel
Created November 16, 2010 21:04
Show Gist options
  • Save stevenheidel/702509 to your computer and use it in GitHub Desktop.
Save stevenheidel/702509 to your computer and use it in GitHub Desktop.
11 Objects to Rows or something for Hubble
objects = [A, B, C, D, E, F, G, H, I...] # your objects
table = []
(objects.length - 1).times do |i|
table << objects[i, 2]
end
@stevenheidel
Copy link
Author

Turns this into that for instance:

ruby-1.9.2-p0 > objects
=> ["a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z"]
ruby-1.9.2-p0 > table
=> [["a", "b"], ["b", "c"], ["c", "d"], ["d", "e"], ["e", "f"], ["f", "g"], ["g", "h"], ["h", "i"], ["i", "j"], ["j", "k"], ["k", "l"], ["l", "m"], ["m", "n"], ["n", "o"], ["o", "p"], ["p", "q"], ["q", "r"], ["r", "s"], ["s", "t"], ["t", "u"], ["u", "v"], ["v", "w"], ["w", "x"], ["x", "y"], ["y", "z"]]

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