Skip to content

Instantly share code, notes, and snippets.

@elreimundo
Last active December 19, 2015 14:09
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 elreimundo/5967472 to your computer and use it in GitHub Desktop.
Save elreimundo/5967472 to your computer and use it in GitHub Desktop.
So I thought this would show a (not-very-well-spaced) times table with individual values separated by a space and each row on a new line. What am I missing?
def times_table(rows)
bigarray = []
1.upto(rows) do |x|
newarrayrow=[]
1.upto(rows) do |y|
newarrayrow << x*y
end
bigarray << newarrayrow.join(' ')
end
puts bigarray.join("\n")
end
@elreimundo
Copy link
Author

Now returns a string, not an array, but it still doesn't quite do what I want it to do.

@elreimundo
Copy link
Author

Important to include puts in the last line

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