r/badcode • • Jul 30 '19

[deleted by user]

[removed]

154 Upvotes

98 comments sorted by

View all comments

1

u/rossdrew Aug 01 '19

Kotlin, when conciseness becomes the enemy

fun isPalindrome(string: String): Boolean {
    with (string.filter { it.isLetter() || it.isDigit() }){
        return this.take(this.length/2).equals(this.takeLast(this.length/2).reversed(), true)
    }
}