Thread Stilfrage: Wert zu (nicht) vorhandem Hasheintrag addieren (6 answers)
Opened by shi8dao at 2011-05-10 14:16

bianca
 2011-05-10 14:53
#148420 #148420
User since
2009-09-13
6978 Artikel
BenutzerIn

user image
2011-05-10T12:42:23 shi8dao
Ich programmiere normalerweise Sprachen, die so was komplizierter behandeln.

Vielleicht sei an der Stelle eine Winzigkeit erwähnt:

Autovivifikation!
Siehe Code:
Code (perl): (dl )
1
2
3
4
5
6
7
8
9
#!/usr/bin/perl -W
use strict;
use warnings;
use Data::Dumper;
my %hash;
if (defined $hash{a} && defined $hash{a}{b}) {}
print "Case 1 without autovivication:\n" , Dumper \%hash;
if (defined $hash{a}{b}) {}
print "Case 2 with autovivication:\n" , Dumper \%hash;

Das muss man wissen, damit man nicht stolpert.
10 print "Hallo"
20 goto 10

View full thread Stilfrage: Wert zu (nicht) vorhandem Hasheintrag addieren