• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/*
2 * Copyright (c) 2022 Huawei Device Co., Ltd.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 * http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15
16
17var N=[3, 4, 5]
18var a = [1, 2, ...N];
19print(...a)
20
21var b = () :number => { return 1 }
22
23print(b())
24
25var c = 1;
26c += c;
27c *= c;
28c -= c;
29c = -c;
30c++;
31++c;
32c--;
33--c;
34print(c)
35
36var d = c != c;
37var e = 1 | 2;
38e = e & 3;
39d = e == 3;
40print(d)
41print(e)
42
43var f = {
44    a: 1,
45    b: "str",
46    c: 1 as number,
47    d: () => { return 1 },
48    e: { a: 1 },
49    f: c = 5,
50    g: [1,2]
51}
52
53print(f.a)
54print(f.b)
55print(f.c)
56print(f.d())
57print(f.e.a)
58print(f.f)
59print(...f.g)
60
61switch (c) {
62    case 0 : print(0);
63    case 5 : print(5);
64    default: print(1);
65}
66