Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

about_basics #34

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 12 additions & 13 deletions about_basics.go
Original file line number Diff line number Diff line change
@@ -1,34 +1,33 @@
package go_koans

func aboutBasics() {
assert(__bool__ == true) // what is truth?
assert(__bool__ != false) // in it there is nothing false
assert(true == true) // what is truth?
assert(true != false) // in it there is nothing false

var i int = __int__
var i int = 1
assert(i == 1.0000000000000000000000000000000000000) // precision is in the eye of the beholder

k := __int__ //short assignment can be used, as well
k := 1 //short assignment can be used, as well
assert(k == 1.0000000000000000000000000000000000000)

assert(5%2 == __int__)
assert(5*2 == __int__)
assert(5^2 == __int__)
assert(5%2 == 1)
assert(5*2 == 10)

var x int
assert(x == __int__) // zero values are valued in Go
assert(x == 0) // zero values are valued in Go

var f float32
assert(f == __float32__) // for types of all types
assert(f == 0.0) // for types of all types

var s string
assert(s == __string__) // both typical or atypical types
assert(s == "") // both typical or atypical types

var c struct {
x int
f float32
s string
}
assert(c.x == __int__) // and types within composite types
assert(c.f == __float32__) // which match the other types
assert(c.s == __string__) // in a typical way
assert(c.x == 0) // and types within composite types
assert(c.f == 0.0) // which match the other types
assert(c.s == "") // in a typical way
}