title: How to implement a functional interface as lambda in Kotlin?
body: <p>I want to implement a functional kotlin interface (interface with a single abstract method) as a kotlin lambda. How to do that?</p>
  
  <p><strong>Kotlin interface</strong></p>
  
  <pre><code>@FunctionalInterface
  interface Foo{
    fun bar(input: String): String 
  }
  </code></pre>
  
  <p><strong>Kotlin implementation</strong> .</p>
  
  <pre><code>fun createFoo(): Foo {
     return { input: String -&gt; "Hello $input!" }
  }
  </code></pre>
  
  <p>↑ doesn't compile ↑ </p>
  
  <p>It has to be implemented as object, which is ugly as hell.</p>
  
  <pre><code>fun createFoo() = 
       object : Foo{
              override fun bar(input: String)= "Hello $input"
       }
  </code></pre>
  
  <hr>
  
  <p>EDIT: corrected my sample interface from java to kotlin</p>