init_optional_with_value.carbon 452 B

123456789101112131415161718
  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. // CHECK:STDOUT: Hallo Welt
  7. // CHECK:STDOUT: result: 0
  8. package ExplorerTest api;
  9. fn Main() -> i32{
  10. var x: Optional(String) = Optional(String).Create( "Hallo Welt" );
  11. if(x.HasValue()){
  12. Print(x.Get());
  13. return 0;
  14. }
  15. return -1;
  16. }