September 2017 Update
This commit is contained in:
parent
bba7bfd280
commit
ba8067c3b7
14570 changed files with 153136 additions and 63871 deletions
|
|
@ -0,0 +1,18 @@
|
|||
// version 1.0.5-2
|
||||
|
||||
/** overload ++ operator to increment a numeric string */
|
||||
operator fun String.inc(): String =
|
||||
try {
|
||||
val num = this.toInt()
|
||||
(num + 1).toString()
|
||||
}
|
||||
catch(e: NumberFormatException) {
|
||||
this // return string unaltered
|
||||
}
|
||||
|
||||
fun main(args: Array<String>) {
|
||||
var ns = "12345"
|
||||
println(++ns)
|
||||
ns = "ghijk" // not numeric, so won't be changed by increment operator
|
||||
println(++ns)
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue