Thread Mehrfachvererbung Perl5 native (16 answers)
Opened by rosti at 2023-11-04 10:40

rosti
 2023-11-04 11:41
#195400 #195400
User since
2011-03-19
3243 Artikel
BenutzerIn
[Homepage]
user image
Ok ;)

Also das ist jetzt echt doof, weil: Es ist genau andersherum.

Code (perl): (dl )
1
2
3
4
5
6
7
use base qw(Boo Foo Bar);
use strict;
use warnings;

my $m = bless{};

$m->whois; # Boo


PS: Ersten Test nochmal gemacht. Es ist tatsächlich so und reproduzierbar: Wer in use base qw(main App) zuerst kommt mahlt zuerst.

Zum Spielen ;)


Code (perl): (dl )
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
package Foo;
sub new{ return bless{},shift }
sub whois{ print __PACKAGE__ }

package Bar;
sub new{ return bless{},shift }
sub whois{ print __PACKAGE__ }

package Boo;
sub new{ return bless{},shift }
sub whois{ print __PACKAGE__ }

package main;

use base qw(Bar Boo Foo);
use strict;
use warnings;

my $m = main->new;
$m->whois;

Last edited: 2023-11-04 16:12:10 +0100 (CET)

View full thread Mehrfachvererbung Perl5 native