File tree 1 file changed +93
-0
lines changed
1 file changed +93
-0
lines changed Original file line number Diff line number Diff line change
1
+ // 1 : int x, float64 y type conversion sample
2
+
3
+ /* package main
4
+
5
+ import "fmt"
6
+
7
+ func main() {
8
+
9
+ x := 75
10
+ var y float64
11
+ y = float64(x) // type(value)
12
+
13
+ fmt.Println(y)
14
+
15
+ } */
16
+
17
+ // 2 : multiple assing sample x, y = y, x
18
+
19
+ /* package main
20
+
21
+ import "fmt"
22
+
23
+ func main() {
24
+ x := 5
25
+ y := 10
26
+
27
+ fmt.Println("X:", x, "Y:", y)
28
+
29
+ x, y = y, x // x = y , y = x
30
+
31
+ fmt.Println("X:", x, "Y:", y)
32
+
33
+ } */
34
+
35
+ // 3 : non English variable names
36
+
37
+ /* package main
38
+
39
+ import "fmt"
40
+
41
+ func main() {
42
+
43
+ yaş := 40
44
+
45
+ fmt.Println(yaş)
46
+
47
+ 名稱 := "Arin"
48
+
49
+ 年齡 := 40
50
+
51
+ fmt.Println("Name:", 名稱, "Age:", 年齡)
52
+
53
+ } */
54
+
55
+ // 4 : shadowing kavramı? gölgeleme
56
+
57
+ /* package main
58
+
59
+ import "fmt"
60
+
61
+ func main() {
62
+ x := 5
63
+
64
+ if true {
65
+ x = 10
66
+ x++
67
+ fmt.Println(x)
68
+ }
69
+
70
+ fmt.Println(x)
71
+ } */
72
+
73
+ // 5 : 40 as a string
74
+
75
+ package main
76
+
77
+ import (
78
+ "fmt"
79
+ "strconv"
80
+ )
81
+
82
+ func main () {
83
+
84
+ x := 65
85
+
86
+ s := string (x )
87
+
88
+ fmt .Printf ("%v, %T\n " , x , x ) // 65
89
+ fmt .Printf ("%v, %T\n " , s , s ) // A
90
+
91
+ y := strconv .Itoa (x )
92
+ fmt .Printf ("%v, %T\n " , y , y ) // "65"
93
+ }
You can’t perform that action at this time.
0 commit comments