Skip to content

Commit 247d466

Browse files
committed
Ders 35
1 parent e2ee062 commit 247d466

File tree

1 file changed

+55
-0
lines changed

1 file changed

+55
-0
lines changed

Diff for: 35_structs_partII/main.go

+55
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
package main
2+
3+
import "fmt"
4+
5+
type employee struct { // underlying type
6+
name string
7+
age int
8+
isMarried bool
9+
}
10+
11+
type manager struct {
12+
employee
13+
hasDegree bool
14+
}
15+
16+
// IS A Relation --> Klasik
17+
// HAS A Relation
18+
19+
func main() {
20+
21+
e1 := employee{
22+
name: "Gurcan",
23+
age: 40,
24+
isMarried: true,
25+
}
26+
27+
fmt.Println(e1)
28+
29+
/* m1 := manager{
30+
employee: employee{
31+
name: "Ayşe",
32+
age: 28,
33+
isMarried: false,
34+
},
35+
hasDegree: true,
36+
} */
37+
38+
m1 := manager{}
39+
m1.name = "Ayşe"
40+
m1.age = 28
41+
m1.isMarried = false
42+
m1.hasDegree = true
43+
44+
fmt.Println(m1)
45+
46+
// Anonim Struct
47+
48+
theBoss := struct {
49+
name string
50+
money bool
51+
}{name: "THE BOSS", money: true}
52+
53+
fmt.Println(theBoss)
54+
55+
}

0 commit comments

Comments
 (0)