From 5b2515784d08c2ebc72675aeab1fdd86a276031a Mon Sep 17 00:00:00 2001 From: Earl St Sauver Date: Wed, 28 Sep 2016 06:29:01 +0300 Subject: [PATCH] Fix Triangle example The current example doesn't work, it prints out each * on a new line. ```console scala> def triangle(side: Int): Unit = { | (1 to side) foreach { row => | (1 to row) foreach { col => | println("*") | } | } | } triangle: (side: Int)Unit scala> triangle(4) * * * * * * * * * * scala> def triangle2(side: Int): Unit = { | (1 to side) foreach { row => | (1 to row) foreach { col => | print("*") | } | print("\n") | } | } triangle2: (side: Int)Unit scala> triangle2(4) * ** *** **** scala> ``` --- docs/11/a.md | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/docs/11/a.md b/docs/11/a.md index 047c378..f379c13 100644 --- a/docs/11/a.md +++ b/docs/11/a.md @@ -33,12 +33,13 @@ scala> def triangle4: Unit = { We can abstract out 4 into a parameter: ```console -scala> def triangle(side: Int): Unit = { - (1 to side) foreach { row => - (1 to row) foreach { col => - println("*") - } - } +scala> def triangle2(side: Int): Unit = { + (1 to side) foreach { row => + (1 to row) foreach { col => + print("*") + } + print("\n") + } } ```