Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

Go Language: Type Conversion

Tags: intvar float

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


Previous                                                 Next                                                 Home


This post first appeared on Java Tutorial : Blog To Learn Java Programming, please read the originial post: here

Share the post

Go Language: Type Conversion

×

Subscribe to Java Tutorial : Blog To Learn Java Programming

Get updates delivered right to your inbox!

Thank you for your subscription

×