Cromm
Cromm

Reputation: 352

Why toUpperCase() is deprecated if uppercase() is experimental?

I got warnings telling me that toUpperCase : String is deprecated and that I need to use uppercase instead. But when using uppercase I have to add the @OptIn(ExperimentalStdlibApi::class) annotation. Which to me does not make sense.

Why do we have to choose between a deprecated method and an experimental one ?

Upvotes: 3

Views: 2898

Answers (2)

Shaharyar Keerio
Shaharyar Keerio

Reputation: 17

Use uppercase(Locale.getDefault() or uppercase() method

Upvotes: 0

Hayssam Soussi
Hayssam Soussi

Reputation: 1083

You are using a Kotlin version where the uppercase was still experimental. As of Kotlin 1.5, this is not experimental anymore.

To solve this, update your Kotlin to 1.5 or above.

To update Kotlin's version:

In the root build.gradle of your project. You will find something like this:

buildscript {
ext.kotlin_version = '1.1.51'
repositories {
    google()
    jcenter()
}

Change the second line to: ext.kotlin_version = '1.6.0'

Upvotes: 2

Related Questions