Hi, is “this” refers to class my_env?
I am assuming if get_env() is not used, then we assign one_env to my_env;
Thanks.
Hi, is “this” refers to class my_env?
I am assuming if get_env() is not used, then we assign one_env to my_env;
Thanks.
In reply to ChChee:
Yes… “this” refers to class my_env.
The ‘this’ keyword is used to refer to class properties, parameters and methods of the current instance.
when class object is created, new() will be called and one_env will assign ‘this’. This process is irrespective of calling get_env() method.
get_env() is only used to get the class handle. calling this function doesn’t change value of ‘one_env’.
In reply to ChChee:
This is a poor example; the code is illegal. You are not allowed to do operations on class variables except for comparisons. It should be
if (one_env==null)…. Also,
one_env is typically declared with a
local or
protected property qualifier to prevent other people from accessing directly.