Thread Nicht benötigte Argumente trotzem in eine Variable kopieren? (29 answers)
Opened by Kuerbis at 2018-02-22 08:19

Kuerbis
 2018-02-23 08:09
#188033 #188033
User since
2011-03-20
938 Artikel
BenutzerIn
[default_avatar]
In Perl kann man dem Konstruktor Daten übergeben:

Quote
The constructor can also accept additional parameters that define the object. Let's write a real constructor for the File class we used earlier:


Code (perl): (dl )
1
2
3
4
5
6
7
8
9
10
package File;
      sub new {
          my $class = shift;
          my ( $path, $data ) = @_;
          my $self = bless {
              path => $path,
              data => $data,
          }, $class;
          return $self;
      }

(https://perldoc.perl.org/perlobj.html)

Für mich sieht es so aus, dass bless ein $self zurück gibt, wobei mir im Laufe der Diskussion aufgefallen ist, das ich in der Dokumention $self als Argument unterschlagen habe.

View full thread Nicht benötigte Argumente trotzem in eine Variable kopieren?