Just wondering -- I keep seeing different syntaxes for creating objects:
my $obj = My::Module->new(); #1vs.
my $obj = new My::Module; #2but I haven't found any documentation about the second case. It seems that I can just use any method name, as in
my $res = some_method $obj;which looks somewhat weird. Is there a rationale or even benefit behind this syntax, or is it just syntactic sugar for the $obj->some_method notation?
What do people prefer to create objects -- syntax #1 or #2? Personally, I think #2 looks sexier, but I'd like to have a rational reason to use it ;-)
In reply to OO style: Placement of "new" by crenz
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |