// a statement of the type:
// T(v)
// where T is a type and v is a value converts
// v to the type T
package main
import (
"fmt"
"math"
)
func main() {
// x and y are of type int
x, y := 3, 4
// can't do this directly!
// math.Sqrt expects a string
// z := math.Sqrt(x * x + y * y)
// you should cast the value first:
z := math.Sqrt(float64(x * x + y * y))
fmt.Println("Type: %T Value: %v", x, x)
fmt.Println("Type: %T Value: %v", y, y)
fmt.Println("Type: %T Value: %v", z, z)
}
To embed this program on your website, copy the following code and paste it into your website's HTML: