The expression
T(v) converts the value v to the type T.
Example
var i int
var j
float32 = 2.34
i = int(j)
App.go
package main import "fmt" func main() { var i int var j float32 = 2.34 i = int(j) var k float32 var l int = 2 k = float32(l) fmt.Println("i = ", i) fmt.Println("j = ", j) fmt.Println("k = ", k) fmt.Println("l = ", l) }
Output
i = 2
j = 2.34
k = 2
l = 2
No comments:
Post a Comment