[netrexx-course] *this* keyword

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

[netrexx-course] *this* keyword

Terry Norton-2
I'm having a mental block understanding the *this* keyword.

Could someone explain to me why I would use *this*?  It just
seems redundant to me so I know I'm not getting the concept for
its use.


Terry Norton
TEN Industries
Nutramerica Independent Associate
http://www.tenindustries.com/
[hidden email]


______________________________________________________________________

Subscribe, unsubscribe, opt for a daily digest, or start a new e-group
at http://www.eGroups.com -- Free Web-based e-mail groups.

Reply | Threaded
Open this post in threaded view
|

[netrexx-course] Re: *this* keyword

dIon Gillard/Multitask Consulting/AU
I'm having a mental block understanding the *this* keyword.
>
> Could someone explain to me why I would use *this*?  It just
> seems redundant to me so I know I'm not getting the concept for
> its use.
You might want to use it to make sure of which variable is getting set.

e.g. given the class:

class Test
   x = "Blah"
method junk(x, y)
   x= 12


Which x is being set?? (The method parameter unfortunately). So if you really want to set the class's property x, use:

   this.x = 12

Clearer??

-----
See the original message at http://www.egroups.com/list/netrexx-course/?start=98
--
Free e-mail group hosting at http://www.eGroups.com/

______________________________________________________________________
Make your travel reservations with Internet Travel Network
http://www.itn.net and
enter to win two round trip First Class airline tickets!

Subscribe, unsubscribe, opt for a daily digest, or start a new e-group
at http://www.eGroups.com -- Free Web-based e-mail groups.