You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: exercises/print_square.rb
+5-2Lines changed: 5 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -13,7 +13,7 @@
13
13
14
14
# The print_line method is here to help you.
15
15
# Conceptually, it prints out a row of "count" *'s. Run it yourself to
16
-
# see how it works. Experiment with different inputs.
16
+
# see how it works. Experiment with xRails params explained?different inputs.
17
17
defprint_line(count)
18
18
(1..count).eachdo |i| # or, equivalently, for i in (1..count)
19
19
print"*"# This prints a single "*"
@@ -25,9 +25,12 @@ def print_line(count)
25
25
# We can call methods we've defined ourselves. In this case, we want
26
26
# to call the print_line method we've defined to help us print out a square.
27
27
defprint_square(dimension)
28
+
28
29
(1..dimension).eachdo |i| # or, equivalently, for i in (1..dimension)
29
-
print_line(2)# Fill in the blank, here.
30
+
print_line(dimension)# Recursion. Kind of. I called the print_line method on the print_square method using the print_square arguement. I don't know what its called. It just works ;).
31
+
print"\n"
30
32
end
33
+
31
34
end
32
35
33
36
# There are no rumble strips this time. It's up to you to decide whether
0 commit comments