Solutions: Printing Shapes Exercises
Use the knowledge gained in this chapter to solve the exercise questions.
We'll cover the following...
Print a rhombus
Press + to interact
hashtag = "#"space = " "width.times do |row|space_count = width - row - 1print space * space_countputs hashtag * widthend
Explanation
Line 4: We subtracted the current row’s value from the total number of rows to calculate spaces. Note that we also subtracted an additional
1
...