func main() {
sstring := fmt.Sprint("Hello ", "World")
nstring := "Hello World"
fmt.Println(sstring)
fmt.Println(nstring)
}
https://go.dev/play/p/WO415NpCkSl
func main() {
Sequence := 254
sstring := fmt.Sprintf("Sequence number %d is on hold", Sequence)
fmt.Println(sstring)
nstring := "Sequence number " + Sequence + "is on hold"
fmt.Println(nstring)
}
https://go.dev/play/p/pm_Vc-iKQUZ
./prog.go:12:13: invalid operation: "Sequence number " + Sequence (mismatched types untyped string and int)
func main() {
Sequence := 254
sstring := fmt.Sprintf("Sequence number %d is on hold", Sequence)
fmt.Println(sstring)
nstring := "Sequence number " + strconv.Itoa(Sequence) + " is on hold"
fmt.Println(nstring)
}
https://go.dev/play/p/8CsnrUY_kzE
Sequence number 254 is on hold
Sequence number 254 is on hold
Quick Sort in Go (0) | 2022.03.17 |
---|---|
28/2 Struct Pointer study (0) | 2022.03.01 |
28/2 mixture of field:value and value initializers error in Go (0) | 2022.02.28 |
27/02 Builder pattern in GO - Construct the ship's Defense Shields (4) | 2022.02.27 |
댓글 영역