-
Notifications
You must be signed in to change notification settings - Fork 0
/
Second.co
46 lines (36 loc) · 1.09 KB
/
Second.co
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
//variant<tuple<lit, int>, tuple<lit, lit>>giveVariant2(int in)
(str, int | str, str)giveVariant2(int in)
{
if (in == 1) return ("ok", 10)
if (in == 2) return ("ok", 88)
else return ("error", "unexpected_int")
}
(int | str)giveVariant3(int in)
{
if (in == 1) return "ok"
if (in == 2) return 88
else return "error"
}
(int | str, int)giveVariant4(int in)
{
if (in == 1) return ("ok", 10)
if (in == 2) return ("ok", 88)
else return 0
}
(int)main()
{
// (str, int | str, str)giveVariant2(1)
// variant<tuple<string,int>, tuple<string, string>> myVari = make_tuple("test", 66);
(str, int | str, str) myVari = giveVariant2(1)
(int, str | str, str | int | int, str, str) varTuple = 54
int test10 = 10
(int, str) test11 = (10, "ok")
match (varTuple)
{
(int i, str s) => cout << "int, str: " << i << " - " << s << "\n"
(str s1, str s2) => cout << "str, str: " << s1 << " - " << s2 << "\n"
(int x) => cout << "int: " << x << "\n"
(int i, str s1, str s2) => cout << "Yolo"
}
return 0
}