Replaced all usages of deprecated toUpperCase/toLowerCase with uppercase/lowercase calls
This commit is contained in:
parent
ff47882ade
commit
ce4c320273
|
@ -4,6 +4,6 @@ import atomictest.eq
|
||||||
fun main() {
|
fun main() {
|
||||||
val list = listOf('a', 'b', 'c', 'd')
|
val list = listOf('a', 'b', 'c', 'd')
|
||||||
val result =
|
val result =
|
||||||
list.map { "[${it.toUpperCase()}]" }
|
list.map { "[${it.uppercaseChar()}]" }
|
||||||
result eq listOf("[A]", "[B]", "[C]", "[D]")
|
result eq listOf("[A]", "[B]", "[C]", "[D]")
|
||||||
}
|
}
|
|
@ -2,9 +2,9 @@
|
||||||
package creatingClassesExercise4
|
package creatingClassesExercise4
|
||||||
|
|
||||||
fun main() {
|
fun main() {
|
||||||
val s: String = "Hello!"
|
val s = "Hello!"
|
||||||
println(s.toUpperCase())
|
println(s.uppercase())
|
||||||
println(s.toLowerCase())
|
println(s.lowercase())
|
||||||
}
|
}
|
||||||
/* Output:
|
/* Output:
|
||||||
HELLO!
|
HELLO!
|
||||||
|
|
|
@ -7,7 +7,7 @@ Press <span class="shortcut">&shortcut:QuickJavaDoc;</span> when the caret is
|
||||||
on a class or a function usage, and IntelliJ IDEA will show you the available
|
on a class or a function usage, and IntelliJ IDEA will show you the available
|
||||||
documentation for this function or class.
|
documentation for this function or class.
|
||||||
|
|
||||||
Put the caret on the `String` type and its `toUpperCase()` and `toLowerCase()` member
|
Put the caret on the `String` type and its `uppercase()` and `lowercase()` member
|
||||||
functions, then use <span class="control">`Quick Documentation`</span>.
|
functions, then use <span class="control">`Quick Documentation`</span>.
|
||||||
Press <span class="shortcut">&shortcut:EditorEscape;</span> to close the
|
Press <span class="shortcut">&shortcut:EditorEscape;</span> to close the
|
||||||
quick documentation pop-up.
|
quick documentation pop-up.
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
fun main() {
|
fun main() {
|
||||||
val s = "AbcD"
|
val s = "AbcD"
|
||||||
println(s.reversed())
|
println(s.reversed())
|
||||||
println(s.toLowerCase())
|
println(s.lowercase())
|
||||||
}
|
}
|
||||||
/* Output:
|
/* Output:
|
||||||
DcbA
|
DcbA
|
||||||
|
|
|
@ -5,7 +5,7 @@ fun isPalindrome(s: String): Boolean =
|
||||||
s.reversed() == s
|
s.reversed() == s
|
||||||
|
|
||||||
fun isPalIgnoreCase(s: String): Boolean =
|
fun isPalIgnoreCase(s: String): Boolean =
|
||||||
isPalindrome(s.toLowerCase())
|
isPalindrome(s.lowercase())
|
||||||
|
|
||||||
fun main() {
|
fun main() {
|
||||||
println(isPalIgnoreCase("Mom")) // true
|
println(isPalIgnoreCase("Mom")) // true
|
||||||
|
|
|
@ -4,7 +4,7 @@ files:
|
||||||
visible: true
|
visible: true
|
||||||
placeholders:
|
placeholders:
|
||||||
- offset: 170
|
- offset: 170
|
||||||
length: 29
|
length: 27
|
||||||
placeholder_text: TODO()
|
placeholder_text: TODO()
|
||||||
- name: test/Tests.kt
|
- name: test/Tests.kt
|
||||||
visible: false
|
visible: false
|
||||||
|
|
|
@ -5,7 +5,7 @@ palindromes. "Bob" should now be considered a palindrome.
|
||||||
|
|
||||||
<div class="hint">
|
<div class="hint">
|
||||||
|
|
||||||
Use `toLowerCase()` to produce a `String` with all lower-case characters.
|
Use `lowercase()` to produce a `String` with all lower-case characters.
|
||||||
You can also use `toUpperCase()`.
|
You can also use `uppercase()`.
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -5,7 +5,7 @@ fun isPalindrome(s: String): Boolean =
|
||||||
s.reversed() == s
|
s.reversed() == s
|
||||||
|
|
||||||
fun isPalIgnoreCase(s: String): Boolean =
|
fun isPalIgnoreCase(s: String): Boolean =
|
||||||
isPalindrome(s.toLowerCase())
|
isPalindrome(s.lowercase())
|
||||||
|
|
||||||
fun isPalIgnoreSpecial(s: String): Boolean {
|
fun isPalIgnoreSpecial(s: String): Boolean {
|
||||||
var onlyLetters = ""
|
var onlyLetters = ""
|
||||||
|
|
|
@ -3,7 +3,7 @@ files:
|
||||||
- name: src/Task.kt
|
- name: src/Task.kt
|
||||||
visible: true
|
visible: true
|
||||||
placeholders:
|
placeholders:
|
||||||
- offset: 248
|
- offset: 246
|
||||||
length: 154
|
length: 154
|
||||||
placeholder_text: TODO()
|
placeholder_text: TODO()
|
||||||
- name: test/Tests.kt
|
- name: test/Tests.kt
|
||||||
|
|
|
@ -7,6 +7,6 @@ operator fun String.invoke(
|
||||||
) = f(this)
|
) = f(this)
|
||||||
|
|
||||||
fun main() {
|
fun main() {
|
||||||
"mumbling" { it.toUpperCase() } eq
|
"mumbling" { it.uppercase() } eq
|
||||||
"MUMBLING"
|
"MUMBLING"
|
||||||
}
|
}
|
|
@ -20,7 +20,7 @@ class TestDataTypesExercise1 {
|
||||||
fun checkTypeMismatch() {
|
fun checkTypeMismatch() {
|
||||||
val output = runAndGetSystemOutput {
|
val output = runAndGetSystemOutput {
|
||||||
main()
|
main()
|
||||||
}.toLowerCase()
|
}.lowercase()
|
||||||
|
|
||||||
Assert.assertTrue("The first line of the error the compiler produces is expected: Type mismatch",
|
Assert.assertTrue("The first line of the error the compiler produces is expected: Type mismatch",
|
||||||
output.contains("type")
|
output.contains("type")
|
||||||
|
|
|
@ -3,13 +3,13 @@ import atomictest.*
|
||||||
|
|
||||||
fun main() {
|
fun main() {
|
||||||
val map = mapOf(1 to "one")
|
val map = mapOf(1 to "one")
|
||||||
map[1]!!.toUpperCase() eq "ONE"
|
map[1]!!.uppercase() eq "ONE"
|
||||||
map.getValue(1).toUpperCase() eq "ONE"
|
map.getValue(1).uppercase() eq "ONE"
|
||||||
capture {
|
capture {
|
||||||
map[2]!!.toUpperCase()
|
map[2]!!.uppercase()
|
||||||
} eq "NullPointerException"
|
} eq "NullPointerException"
|
||||||
capture {
|
capture {
|
||||||
map.getValue(2).toUpperCase()
|
map.getValue(2).uppercase()
|
||||||
} eq "NoSuchElementException: " +
|
} eq "NoSuchElementException: " +
|
||||||
"Key 2 is missing in the map."
|
"Key 2 is missing in the map."
|
||||||
}
|
}
|
|
@ -3,9 +3,9 @@ package safecalls
|
||||||
import atomictest.*
|
import atomictest.*
|
||||||
|
|
||||||
fun String.echo() {
|
fun String.echo() {
|
||||||
trace(toUpperCase())
|
trace(uppercase())
|
||||||
trace(this)
|
trace(this)
|
||||||
trace(toLowerCase())
|
trace(lowercase())
|
||||||
}
|
}
|
||||||
|
|
||||||
fun main() {
|
fun main() {
|
||||||
|
|
|
@ -3,7 +3,7 @@ package safeCallsAndTheElvisOperatorExercise1
|
||||||
import atomictest.eq
|
import atomictest.eq
|
||||||
|
|
||||||
fun downcase(s: String?): String =
|
fun downcase(s: String?): String =
|
||||||
s?.toLowerCase() ?: ""
|
s?.lowercase() ?: ""
|
||||||
|
|
||||||
fun main() {
|
fun main() {
|
||||||
downcase(null) eq ""
|
downcase(null) eq ""
|
||||||
|
|
|
@ -4,9 +4,9 @@ files:
|
||||||
visible: true
|
visible: true
|
||||||
placeholders:
|
placeholders:
|
||||||
- offset: 98
|
- offset: 98
|
||||||
length: 59
|
length: 57
|
||||||
placeholder_text: fun downcase() {}
|
placeholder_text: fun downcase() {}
|
||||||
- offset: 172
|
- offset: 170
|
||||||
length: 49
|
length: 49
|
||||||
placeholder_text: |-
|
placeholder_text: |-
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -9,7 +9,7 @@ class TestSafeCallsAndTheElvisOperatorExercise1 {
|
||||||
val downcaseFunc = ::downcase
|
val downcaseFunc = ::downcase
|
||||||
checkParametersOfTopLevelFunction(downcaseFunc, listOf("" to "kotlin.String?"))
|
checkParametersOfTopLevelFunction(downcaseFunc, listOf("" to "kotlin.String?"))
|
||||||
val actual = downcaseFunc.call(s)
|
val actual = downcaseFunc.call(s)
|
||||||
Assert.assertEquals("Wrong result for calling downcase(\"$s\")", s?.toLowerCase() ?: "", actual)
|
Assert.assertEquals("Wrong result for calling downcase(\"$s\")", s?.lowercase() ?: "", actual)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
Loading…
Reference in New Issue