assign_builtin.carbon 572 B

1234567891011121314151617181920212223242526
  1. // Part of the Carbon Language project, under the Apache License v2.0 with LLVM
  2. // Exceptions. See /LICENSE for license information.
  3. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  4. //
  5. // AUTOUPDATE
  6. package ExplorerTest api;
  7. class C {
  8. var n: i32;
  9. }
  10. fn Main() -> i32 {
  11. var c: C = {.n = 1};
  12. Print("Before: {0}", c.n);
  13. c.(AssignWith({.n: i32}).Op)({.n = 2});
  14. Print("Interface: {0}", c.n);
  15. c = {.n = 3};
  16. Print("Op: {0}", c.n);
  17. return 0;
  18. }
  19. // CHECK:STDOUT: Before: 1
  20. // CHECK:STDOUT: Interface: 2
  21. // CHECK:STDOUT: Op: 3
  22. // CHECK:STDOUT: result: 0