Peter Mandeljc
07/25/2023, 11:45 AMconst val name = "String"
fun getSmth(name: String = name) = TODO("")
In a class scenario, I could use this
keyword, like so:
object X {
const val name = "String"
fun getSmth(name: String = this.name) = TODO("")
}
I know I can rename stuff, but I'm just wondering if it's possible to achieve that somehowJoffrey
07/25/2023, 12:06 PMname
is a general name. It could have different values depending on the named thing. The constant can't be named name
, because it has to be the name of something specific. It could be myThingName
for instance.Joffrey
07/25/2023, 12:09 PMJoffrey
07/25/2023, 12:10 PMmkrussel
07/25/2023, 12:17 PMPeter Mandeljc
07/25/2023, 12:20 PMNAME
, I guess you're right 🙃Peter Mandeljc
07/25/2023, 12:20 PMmkrussel
07/25/2023, 12:23 PMgetSmth
. That will give you a clue about how to name the constant.Joffrey
07/25/2023, 12:33 PMJoffrey
07/25/2023, 12:36 PMpackage
clause). And also, you have to be sure that you don't have a variable name in scope that would match a single-identifier package.
For instance, if your package is example
but you also have a local property named example
, example.name
doesn't compile:
https://pl.kotl.in/h5MpcW1zYPeter Mandeljc
07/25/2023, 12:42 PM