Created
January 24, 2010 18:07
-
-
Save uasi/285344 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class A { | |
has ($.foo, $.bar, $.baz, $.qux, $.blahblahblah); | |
# Is there a way to define a constructor that takes positional arguments | |
# and initializes attributes of the same name | |
# (I assume the definition looks like this) | |
# | |
method NEW ($!foo, $!bar, $!baz, $!qux, $!blahblahblah) { } | |
# ... instead of repeating variables to bless? | |
# | |
method new ($foo, $bar, $baz, $qux, $blahblahblah) { | |
self.bless(*, :$foo, :$bar, :$baz, :$qux, :$blahblahblah); # not so DRY, is it? | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment