Object::Pad Yuki Kimoto's 2021-08-25 - Default internal data structure of the object

Object::Pad Yuki Kimoto's 2021-08-25(I fix this entry because default internal data structure is array reference, not hash reference).

This time is default internal data structure of the object.

Default internal data structure of the Object::Pad is array reference.

use strict;
use warnings;
use Data::Dumper;

use Object::Pad;
 
class Point {
   has $x :param = 1;
   has $y :param = 2;
   
   method dump {
      # Default data structure is array reference
      warn Data::Dumper::Dumper $self;
   }
 
   method describe {
      print "A point at ($x, $y)\n";
   }
}

{
  my $x = 5;
  my $y = 10;
  my $point = Point->new(x => $x, y => $y);
  $point->dump;
}

Leave a comment

About Yuki Kimoto

user-pic I'm Perl Programmer. I LOVE Perl. I want to contribute Perl community and Perl users.