Skip to content

Instantly share code, notes, and snippets.

@elreimundo
Last active December 19, 2015 14:09
Show Gist options
  • Select an option

  • Save elreimundo/5967472 to your computer and use it in GitHub Desktop.

Select an option

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
Copy Markdown
Author

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

@elreimundo

Copy link
Copy Markdown
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