It's not really quite accurate to say that you no longer define your own
new. It's merely the case that you get a default
new for free. However, that default constructor only handles named parameters. If you want a constructor that uses positional parameters, you have to define your own, and there's no reason you can't call it call it
new if you like, presuming it's something that multimethod dispatch can sort out from the default
Object.new().
By the way, I disagree slightly with chromatic on this point. I think new Foo without colon is just fine, since we've gone to some pains to make sure that 1) it works as MMD and that 2) neither the method name nor the class name are taken as barewords. You could just as easily write new(Foo) and it will still work via MMD.
But there's nothing wrong with the colon, and different people value different kinds of consistency.
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.