RE: What is 'new' doing?



Mathew Snyder <theillien@xxxxxxxxx> asked:
In this line of code what is 'new' doing?
my $users = new RT::Users(RT::SystemUser);

It's trying to look like a Perl built-in when
in fact it's just a method of the RT::Users
class.The above code is equivalent to writing

my $users = RT::Users->new(RT::SystemUser);

i.e. call the method new() of the class RT::Users
with an argument of RT::SystemUser.

The important thing here is to realize that
in Perl, you can call your constructor whatever
you like - though it's a nice gesture to stick
to open standards like using "new" for it ;-) -
and that you have two equivalent notations for
method calls.

HTH,
Thomas
.