in reply to Re^6: how to let sub return hash of 2 sub?
in thread how to let sub return hash of 2 sub?
I don't see the point of changing
toreturn NameValTuple->new( name => $name, val => $val ); { package NameValTuple; sub new { my $class = shift; bless({ @_ }, $class) } sub name { $_[0]->{name} } sub val { $_[0]->{val} } }
return bless { name => $name, val => $val }, 'NameValTuple'; { package NameValTuple; sub name { $_[0]->{name} } sub val { $_[0]->{val} } }
It breaks encapsulation for no reason.
|
|---|