Guest User

Untitled

a guest
Sep 22nd, 2019
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Perl 6 0.62 KB | None | 0 0
  1. class GameMap {
  2.   has Int $.x_dim;
  3.   has Int $.y_dim;
  4.   has Array[Int] @.map;
  5.  
  6.  
  7.   method generate_new_empty_map() {
  8.     my Array[Int] @t_map = Array[Int].new,;
  9.     for 0..$.x_dim -> $x_i {
  10.       for 0..$.y_dim -> $y_i {
  11.         print "$x_i - $y_i\n";
  12.         @t_map[$x_i][$y_i] = 0;
  13.       }
  14.     }
  15.     @!map = @t_map;
  16.   }
  17. }
  18.  
  19. # ERROR: 0 - 0
  20. # 0 - 1
  21. # 0 - 2
  22. # 0 - 3
  23. # 0 - 4
  24. # 0 - 5
  25. # 1 - 0
  26. # Type check failed in assignment to @t_map[1]; expected Array[Int] but got Array ($[])
  27. #   in block  at puzzle.p6 line 17
  28. #   in method generate_new_empty_map at puzzle.p6 line 14
  29. #  in block <unit> at puzzle.p6 line 90
Add Comment
Please, Sign In to add comment