app.d 430 B

1234567891011121314151617181920212223242526
  1. void fun(int x)
  2. {
  3. x += 42;
  4. }
  5. void gun(int[] x)
  6. {
  7. x = [ 1, 2, 3 ];
  8. }
  9. void hun(int[] x)
  10. {
  11. x[0] = x[1];
  12. }
  13. unittest
  14. {
  15. int x = 10;
  16. fun(x);
  17. assert(x == 10); // Ничего не изменилось
  18. int[] y = [ 10, 20, 30 ];
  19. gun(y);
  20. assert(y == [ 10, 20, 30 ]); // Ничего не изменилось
  21. hun(y);
  22. assert(y == [ 20, 20, 30 ]); // Изменилось!
  23. }