Okay, I understand. I don't do anything. Hiedra -----Mensaje original----- De: Josh Tynjala <joshtynj...@bowlerhat.dev> Enviado el: martes, 10 de diciembre de 2024 18:51 Para: dev@royale.apache.org Asunto: Re: Warning: Encountered 'this' keyword within closure
No, [this] is not correct. That places "this" into an array. Then, it tries to access the 'mapView' field on the array instead of on this. Unfortunately, there isn't always a good way to work around this warning. Sometimes, you can store the value in a local variable in the outer scope, and then use that variable instead of "this" within the closure. However, that's not always possible. We added this warning to the Royale compiler a few updates back, but it feels like cases where you want to use this in a local function are a bit more common than expected. I'm actually considering disabling this warning by default, and developers can opt in if they like it. -- Josh Tynjala Bowler Hat LLC <https://bowlerhat.dev> On Tue, Dec 10, 2024 at 4:17 AM Maria Jose Esteve <mjest...@iest.com> wrote: > This warning appears many times. Some examples: > > "get": function():*{return this} > "get": function():* { return this._xmlArray[idx]; } > this.append(newValue); (this['mapView'] as > GoogleMapView).finishInitialization(); > > Would simply "[this]" be correct? (I have tested it in > "([this]['mapView'] as GoogleMapView).finishInitialization();": it > produces no error and the warning is gone) > > Thx. > Hiedra > >