title: How can I assign a variable with the value of another variable in Kotlin?
body: <p>In Code A, the parameters <code>x1</code> and <code>x2</code> use the same vaule, it works well.</p>
  <p>I think I can improve Code A, so I write Code B, but it failed.</p>
  <p>How can I assign <code>x2</code> with the value of <code>x1</code> ?</p>
  <p><strong>Code A</strong></p>
  <pre><code>val stepWidth = step * index
  it.drawChildnAxis(
     x1 = stepWidth.toX, y1 = 0f.toY,
     x2 = stepWidth.toX, y2 = yAxisLength.toY
  )
  
  fun Canvas.drawChildnAxis(x1:Float, y1:Float,x2:Float,y2:Float){
      drawLine(
          Offset(x = x1, y = y1),
          Offset(x = x2, y = y2),
          paintTableAxisChild
      )
  }
  </code></pre>
  <p><strong>Code B</strong></p>
  <pre><code>it.drawChildnAxis(
     x1 = step * index.toX, y1 = 0f.toY,
     x2 = x1, y2 = yAxisLength.toY
  )
  
  //The same
  </code></pre>