title: Problems with nested while loops in Kotlin
body: <p>So I was trying to create a function called <code>createSquare()</code> where the first argument is the character used to create the square and the second argument is it's side length, should have worked like</p>
  
  <pre><code>createSquare('a', 3)
  /* Output is 
  aaa
  aaa
  aaa
  */
  </code></pre>
  
  <p>Now I tried using the while loop to achieve this in the following way.</p>
  
  <pre><code>fun createSquare(character: Char = '*', side:Int = 3){
    var i = 0
    var j = 0
    while(i &lt; side){
      while(j &lt; side){
        print(character)
        ++j
      }
      print('\n')
      ++i
    } 
  }
  
  fun main(args: Array&lt;String&gt;) {
    createSquare() // Default arguments passed
  }
  </code></pre>
  
  <p>And this is how I thought the nested while loops would work:</p>
  
  <ol>
  <li><p>Execute the inner while loop</p></li>
  <li><p>Linespace moves the output cursor to the next line</p></li>
  <li><p><code>i</code> increments by 1</p></li>
  <li><p>Steps 1-3 happen again till  <code>i</code> becomes 3, stopping the whole nested loop </p></li>
  </ol>
  
  <p>However this is the output instead:</p>
  
  <pre><code>*** //Output
  
  /*
  Where I expected
  
  
  ***
  ***
  ***
  
  */
  </code></pre>
  
  <p>There might be silly errors in my code as yet I'm a novice programmer.</p>
  
  <p>Thanks in advance!</p>