Thread Frage zu "type annotations" (2 answers)
Opened by rakudo at 2011-02-19 09:54

Gast rakudo
 2011-02-19 09:54
#145765 #145765
Warum darf ich soetwas nicht machen?

Code (perl): (dl )
1
2
3
4
5
6
7
8
9
10
11
12
13
14
#!perl6
use v6;

my %hash = classify { chr $_ }, 97..102;

my Int $eins;
my Int $zwei;

sub routine ( $a, $b ) {
        ( $eins, $zwei ) = %hash{$a, $b};
        return $eins, $zwei;
}

routine( 'a', 'c' ).perl.say;

Code: (dl )
1
2
3
4
Type check failed for assignment
in '&infix:<=>' at line 1
in 'routine' at line 1
in main program body at line 14:./perl.pl


Wenn ich statt
Code (perl): (dl )
1
2
my Int $eins;
my Int $zwei;

Code (perl): (dl )
1
2
my $eins;
my $zwei;

schreibe, dann funktioniert es.
Last edited: 2011-02-19 10:02:06 +0100 (CET)

View full thread Frage zu "type annotations"