mike_shysh
11/06/2017, 1:57 PMfun CustomerInfo.addRandomPartToName(): CustomerInfo {
val oldItem = this.customerInfo <<<< `this` is not usable
val newItem = oldItem?.copy(name = oldItem.name + RandomStringUtils.randomAlphabetic(7))
return this.copy(customerInfo = newItem)
}
menegatti
11/06/2017, 2:01 PMoldItem
should be only this
as that is the scope of your extensionmike_shysh
11/06/2017, 2:03 PMError:(27, 24) Kotlin: Unresolved reference: customerInfo
Error:(29, 22) Kotlin: Cannot find a parameter with this name: customerInfo
customerInfo
is redval oldItem = this.customerInfo
this.copy(customerInfo = newItem)
menegatti
11/06/2017, 2:04 PMthis
is already CustomerInfo
mike_shysh
11/06/2017, 2:05 PMmenegatti
11/06/2017, 2:05 PMthis
will always be the instance of the type to which the extension belongs tofun String.foo() = this.append("a")
for instancemike_shysh
11/06/2017, 2:06 PM