The best explanation that I can give is that all the remaining clauses
are actually the same type, interface{}
Cheers
Dave
On Thu, Sep 15, 2011 at 8:41 AM, d_smi...@rocketmail.com
<d_smi...@rocketmail.com> wrote:
> Why does the following program print "integer!"? I expected it to print
> "object!" or maybe "string!".
> package main
> import "fmt"
> func showObject(o Object) {
> switch o.(type) {
> case int:
> fmt.Println("int!")
> case Integer:
> fmt.Println("integer!")
> case String:
> fmt.Println("string!")
> case Object:
> fmt.Println("object!")
> }
> }
> type Object interface{}
> type String Object
> type Integer Object
> func main() {
> a := String("foo")
> showObject(a)
> }
> (I find this program here https://gist.github.com/1217938)