Last active
December 29, 2015 04:09
-
-
Save kenjiskywalker/7612434 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| #!/usr/bin/env perl | |
| package Hoge; | |
| use Moo; | |
| has num => (is => "rw", default => 1 ); | |
| has numnum => (is => "rw", default => sub { 1 } ); | |
| # has array => (is => "rw", default => ["aaa", "bbb"] ); # not a coderef or a non-ref or code-convertible | |
| has array => (is => "rw", default => sub {["aaa", "bbb"]} ); | |
| has scalar => (is => "rw", default => "aaa"); | |
| 1; | |
| package Main; | |
| use strict; | |
| use warnings; | |
| use utf8; | |
| use DDP; | |
| my $h = Hoge->new(); | |
| p $h->num; | |
| p $h->numnum; | |
| p @{$h->array}; | |
| p $h->scalar; | |
| 1; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment