Created
May 27, 2014 02:12
-
-
Save yoshprogrammer/f64634dc28c927216a22 to your computer and use it in GitHub Desktop.
print_square_attempt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def print_line(count) | |
for i in 1..count | |
print "*" # This prints a single "*" | |
end | |
print "\n" # This forces the output to the next like, like hitting "return" on the keyboard | |
end | |
# We can call methods we've defined ourselves. In this case, we want | |
# to call the print_line method we've defined to help us print out a square. | |
def print_square(dimension) | |
for i in 1..dimension | |
print_line(dimension) # Fill in the blank, here. | |
end | |
end | |
print_square(1) | |
print "\n\n\n" # This is here just to make the separation between squares clearer | |
print_square(2) | |
print "\n\n\n" # This is here just to make the separation between squares clearer | |
print_square(3) | |
print "\n\n\n" # This is here just to make the separation between squares clearer | |
print_square(10) | |
# For my understanding, this code basically says for each (dimension) input print one line. So it's basically | |
# prints a grid of whatever input you have. I am a little confused with the ' for i in 1....dimension'. What does | |
# that line mean exactly? I get what the overall program does, well my interpretation of it. | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment