forked from sujithps/go-koans
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathabout_basics.go
62 lines (44 loc) · 1.15 KB
/
about_basics.go
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
package go_koans
import (
"fmt"
"math"
)
func aboutBasics() {
assert(true == true) // what is truth?
assert(true != false) // in it there is nothing false
var i int = 1
var j int = 42
println(j)
assert(i == 1.0000000000000000000000000000000000000) // precision is in the eye of the beholder
k := 1 //short assignment can be used, as well
assert(k == 1.0000000000000000000000000000000000000)
var odd int = 1
ten := 10
//constants are not infered types
const FIVE = 5
TWENTY_FIVE := math.Pow(FIVE, 2)
fmt.Println(5^3, TWENTY_FIVE)
assert(5%2 == odd)
assert(5*2 == ten)
// XOR , 101 ^ 100 = 001
// XOR , 101 ^ 011 = 110 -> 6
assert(5^4 == odd)
var x int
const ZERO = 0
assert(x == ZERO) // zero values are valued in Go
const ZERO_DECIMAL = 0.0
var f float32
assert(f == ZERO_DECIMAL) // for types of all types
var s string
var void string = ""
assert(s == void) // both typical or atypical types
var c struct {
x int
f float32
s string
}
VOID := ""
assert(c.x == ZERO) // and types within composite types
assert(c.f == ZERO_DECIMAL) // which match the other types
assert(c.s == VOID) // in a typical way
}