User Tools

Site Tools


programming:mojo

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
programming:mojo [2018/10/24 12:32] – created clemixprogramming:mojo [2020/01/26 20:08] (current) clemix
Line 13: Line 13:
   %% Replaced with "%", useful for generating templates   %% Replaced with "%", useful for generating templates
  
 +
 +====== Constructor ======
 +<code perl>
 +sub new {
 +  my $class = shift;
 +  bless @_ ? @_ > 1 ? {@_} : {%{$_[0]}} : {}, ref $class || $class;
 +}
 +</code>
 +
 +<code perl>
 +sub new {
 +    my ($class, $aaa) = @_;
 +    my $self;
 +    if (ref($class) ne '' && $class->isa('my_expected_subclass')) {
 +        $self = $class;
 +    } else {
 +        $self = bless {class => $class}, $class;
 +    }
 +
 +    $self->{xyz}      = $aaa;
 +
 +    return $self;
 +}
 +</code>
programming/mojo.1540377129.txt.gz · Last modified: by clemix

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki