Activity Forums Salesforce® Discussions When to use "this" keyword while writing the extension classes in Salesforce?

  • PRANAV

    Member
    September 19, 2016 at 5:20 am

    Hi Mohit,

    The keyword this is used to explicitly call out that the code is referencing a member of the object. Using it indicates that you explicitly want the member belonging to this instance (as opposed to a static, base, or super instance related to your object.)

    Most often this is used to differentiate between constructor variables and member variables of the same name (or in other cases where it's ambiguous which variable you're referring to).

    This keyword used to represent the current instance of the class.We use this keyword to differentiate between class instance variable and local variable.

    Hope this helps you.

    Thanks

Log In to reply.

Popular Salesforce Blogs

Popular Salesforce Videos