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 PMmenegatti
11/06/2017, 2:02 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: customerInfomike_shysh
11/06/2017, 2:03 PMError:(29, 22) Kotlin: Cannot find a parameter with this name: customerInfomike_shysh
11/06/2017, 2:03 PMcustomerInfo is redmike_shysh
11/06/2017, 2:03 PMval oldItem = this.customerInfomike_shysh
11/06/2017, 2:04 PMthis.copy(customerInfo = newItem)menegatti
11/06/2017, 2:04 PMthis is already CustomerInfomike_shysh
11/06/2017, 2:05 PMmike_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 tomenegatti
11/06/2017, 2:06 PMfun String.foo() = this.append("a") for instancemike_shysh
11/06/2017, 2:06 PM