title: Kotlin dynamically compile a class from source code at runtime
body: <p>Is it possible to compile and instantiate Kotlin class at runtime? I'm talking about something like that but using Kotlin API: <a href="https://stackoverflow.com/questions/2946338/how-do-i-programmatically-compile-and-instantiate-a-java-class">How do I programmatically compile and instantiate a Java class?</a> </p>
  
  <p>As example:
  I'm getting full class definition as String: </p>
  
  <pre><code>val example = "package example\n" +
          "\n" +
          "fun main(args: Array&lt;String&gt;) {\n" +
          "    println(\"Hello World\")\n" +
          "}\n"
  </code></pre>
  
  <p>And then inserting it into some class.kt and running it so I'm getting "Hello World" printed in console at runtime.</p>