41825ab5c05035b745274af45b5d041d5339b5b8
Perl/Object-Simple.md
... | ... | @@ -153,24 +153,27 @@ abs: 7.07106781186548 |
153 | 153 | displayname => '山田 太郎',
|
154 | 154 | );
|
155 | 155 | print "${user}\n";
|
156 | + print "displayname: " . $user->displayname . "\n";
|
|
157 | + $user->account('JiroT');
|
|
158 | + $user->displayname('高橋 次郎');
|
|
159 | + print "${user}\n";
|
|
156 | 160 | |
157 | 161 | exit;
|
158 | 162 | |
159 | 163 | BEGIN {
|
160 | 164 | |
161 | - package User {
|
|
162 | - use Object::Simple -base;
|
|
163 | - use overload '""' => \&stringify;
|
|
165 | + package User;
|
|
166 | + use Object::Simple -base;
|
|
167 | + use overload '""' => \&stringify;
|
|
164 | 168 | |
165 | - has id => '';
|
|
166 | - has account => '';
|
|
167 | - has displayname => '';
|
|
169 | + has id => '';
|
|
170 | + has account => '';
|
|
171 | + has displayname => '';
|
|
168 | 172 | |
169 | - sub stringify {
|
|
170 | - my $self = shift;
|
|
171 | - return sprintf( '{id:"%s", account:"%s", displayname:"%s"}',
|
|
172 | - $self->id, $self->account, $self->displayname );
|
|
173 | - }
|
|
173 | + sub stringify {
|
|
174 | + my $self = shift;
|
|
175 | + return sprintf( '{id:"%s", account:"%s", displayname:"%s"}',
|
|
176 | + $self->id, $self->account, $self->displayname );
|
|
174 | 177 | }
|
175 | 178 | }
|
176 | 179 | ```
|