overload_ops.pl
Perl•マスター
Explorer
C40
C++40
C#40
Dart40
Go40
Java40
JavaScript40
Kotlin40
Objective-C40
Perl
初級10
中級10
上級10
エキスパート5
マスター5
moose_class.pl
tie_hash.pl
closure_factory.pl
overload_ops.pl
autoload_method.pl
PHP40
Python40
R40
Ruby40
Rust40
Shell40
Swift40
TypeScript40
overload_ops.pl
Click to focus
1
2
3
4
5
6
7
8
9
10
11
12
package Point;↵
use overload↵
'+' => sub {↵
Point->new($_[0]->{x} + $_[1]->{x},↵
$_[0]->{y} + $_[1]->{y})↵
},↵
'""' => sub { "($_[0]->{x},$_[0]->{y})" };↵
↵
sub new {↵
my ($class, $x, $y) = @_;↵
bless {x => $x, y => $y}, $class;↵
}
0WPM•0%•0:00•0/259(0%)|Ln 1, Col 1
UTF-8•Perl