Thread OOP Array in einem Hash of Array sortieren (12 answers)
Opened by der_thomas at 2014-03-14 21:25

FIFO
 2014-03-15 22:13
#174150 #174150
User since
2005-06-01
469 Artikel
BenutzerIn

user image
2014-03-15T11:11:00 der_thomas
@FIFO
Danke, das funktioniert so wie von Dir beschrieben.


ok. Noch eine Anmerkung zu Deiner Art der Argumentverarbeitung in der 'sort'-Methode:
Quote
Code (perl): (dl )
1
2
3
4
5
sub sort {
    my $self = shift;
    my $spalte;
    unless (@_){$spalte = $self->{maxspalte}-2} # hier unwichtig
    else {$spalte = shift}                      # hier unwichtig


Übersichtlicher geht das z.B. so:
Code (perl): (dl )
1
2
3
4
5
sub mySort {
    my ( $self, $spalte ) = @_;
    if ( ! defined $spalte ) {
        $spalte = $self->{maxspalte} - 2;
    }


Das @_-Argumentarray so auszupacken erleichtert auch ein späteres Erweitern der Argumentliste.

Editiert von FIFO: typo
Last edited: 2014-03-15 22:33:39 +0100 (CET)
Everyone knows that debugging is twice as hard as writing a program in the first place. So if you're as clever as you can be when you write it, how will you ever debug it? -- Brian Kernighan: "The Elements of Programming Style"

View full thread OOP Array in einem Hash of Array sortieren