in reply to What's the point of this 'overload' idiom?
Because
is nicer thansay $instance;
say $instance->as_string;
That's it. Because it's nice.
And it's not like it takes anything away. When's the last time you saw Class=HASH(0xDEADBEEF) and thought it was useful?[1]
But it's best to give the choice, though.
use overload '""' => \&as_string; sub as_string { my $self = shift; ... }
|
---|