Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
import okio.buffer
import okio.source
/**
* Converts a Kotlin file with `backtick method names` to camelCaseMethodNames.
*/
fun main() {
val source = System.`in`.source().buffer()
while (true) {
val line = source.readUtf8Line() ?: break
val prefix = " fun `"
val suffix = "`() {"
if (!line.startsWith(prefix) || !line.endsWith(suffix)) {
System.out.println(line)
continue
}
val words = line.substring(prefix.length, line.length - suffix.length).split(" ")
val camelWords = words[0] + (words.subList(1, words.size).joinToString(separator = "") { word ->
word.substring(0, 1).toUpperCase() + word.substring(1)
})
System.out.println(" fun ${camelWords}() {")
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment