Return from lambdas or Kotlin: 'return' is not allowed here
<p>I am trying to write function which will tell me that string is nice, nice means string has at least one repetition of letters in the string. But I can't to make return from lambda, it's always return false, though condition in if statement passed. Can somebody explain me how make return?</p>

<p>I have tried to write return, but IDEA gave me the message <strong>Kotlin: 'return' is not allowed here</strong></p>

<pre><code>fun main(args: Array&lt;String&gt;) {
    println("sddfsdf".isNice())
}

fun String.isNice(): Boolean {
    val hasRepeat = {
        for (i in 0 .. (length - 2)) {
            if (subSequence(i, i + 2).toSet().size == 1) {
                true
                println(subSequence(i, i + 2))
            }
        }
        false
    }

    return hasRepeat()
}
</code></pre>

<p>ouput is:</p>

<pre><code>dd
false
</code></pre>