func (person *Person) Move(address string) string {
person.Address, address = address, person.Address
return address
}
person.Address, address = address, person.Address
return address
}
2017-04-10
package main
import (
"fmt"
"math/rand"
)
func main() {
ia := []interface{}{byte(6), 'a', uint(10), int32(-4)}
switch v := ia[rand.Intn(4)]; interface{}(v).(type) {
case int32 :
fmt.Printf("Case A.")
case byte :
fmt.Printf("Case B.")
default:
fmt.Println("Unknown!")
}
}
import (
"fmt"
"math/rand"
)
func main() {
ia := []interface{}{byte(6), 'a', uint(10), int32(-4)}
switch v := ia[rand.Intn(4)]; interface{}(v).(type) {
case int32 :
fmt.Printf("Case A.")
case byte :
fmt.Printf("Case B.")
default:
fmt.Println("Unknown!")
}
}
2017-04-06