RosettaCodeData/Task/Test-a-function/Kotlin/test-a-function.kotlin
2017-09-25 22:28:19 +02:00

15 lines
392 B
Text

// version 1.1.3
fun isPalindrome(s: String) = (s == s.reversed())
fun main(args: Array<String>) {
val testCases = listOf("racecar", "alice", "eertree", "david")
for (testCase in testCases) {
try {
assert(isPalindrome(testCase)) { "$testCase is not a palindrome" }
}
catch (ae: AssertionError) {
println(ae.message)
}
}
}