title: What's an inline constructor in Kotlin?
body: <p>First of all, I have to clarify I'm not asking what's an inline function is or what's an inline class is.
  There's nowhere in Kotlin Language documentation or specification any reference to an inline constructor but if you look in <a href="https://github.com/JetBrains/kotlin/blob/92d200e093c693b3c06e53a39e0b0973b84c7ec5/core/builtins/native/kotlin/Arrays.kt" rel="nofollow noreferrer"><code>Arrays.kt</code></a> source you see this class: <a href="https://kotlinlang.org/spec/built-in-types-and-their-semantics.html#built-in-array-types" rel="nofollow noreferrer"><code>ByteArray</code></a> has an inline constructor:</p>
  <pre class="lang-kotlin prettyprint-override"><code>/**
   * An array of bytes. When targeting the JVM, instances of this class are represented as `byte[]`.
   * @constructor Creates a new array of the specified [size], with all elements initialized to zero.
   */
  public class ByteArray(size: Int) {
      /**
       * Creates a new array of the specified [size], where each element is calculated by calling the specified
       * [init] function.
       *
       * The function [init] is called for each array element sequentially starting from the first one.
       * It should return the value for an array element given its index.
       */
      public inline constructor(size: Int, init: (Int) -&gt; Byte)
  </code></pre>
  <p>Let's consider we want to create a similar class, something like this:</p>
  <pre class="lang-kotlin prettyprint-override"><code>    public class Student(name: String) {
          public inline constructor(name: String, age: Int) : this(name)
      }
  </code></pre>
  <p>If you try to create that class in Kotlin and write an inline constructor for it you see that it's impossible and IDE refers to this error:</p>
  <blockquote>
  <p>Modifier 'inline' is not applicable to 'constructor'</p>
  </blockquote>
  <p>So let's recap, how <code>ByteArray</code> definition is correct?</p>