*Hello*

*A beginner question :*

*Why doesn't work this :*

package main

import (
    "fmt"
)

func PrintAll(vals []interface{}) {
    for _, val := range vals {
        fmt.Println(val)
    }
}

func main() {
    names := []string{"stanley", "david", "oscar"}                        
<-----error
    PrintAll(names)
}



*and Why does it work?  :*




package main

import (
        "fmt"
)

func PrintAll(vals interface{}) {
    fmt.Println(vals)
}

func main() {
        names := "stanley"                                      <---why not 
error here
        PrintAll(names)
}


*The only difference is : first sample is slice of string , second is only a 
string*


*thank you in advance Attila*






-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to