3 ms·
Doesn't compile though. You'll need lots of extra lines just to see an output, which is really much of what the posted article was talking about with its wander
by vorg 12y ago
Doesn't compile though. You'll need lots of extra lines just to see an output, which is really much of what the posted article was talking about with its wandering-eyed gopher tale...
package main
import "fmt"
func main(){
fmt.Println(name(28))
}
type T struct{name string; valid bool}
func get(ref int64) (T, bool) {
return T{"abc", true}, false
}
func name(ref int64) string {
switch data, ok := get(ref); true {
case !ok:
return "No Data"
case !data.valid:
return "Invalid Data"
case data.name == "":
return "New Data"
default:
return data.name
}
}