#what is the difference between these two keywords ?
11 messages · Page 1 of 1 (latest)
package main
import "fmt"
func main(){
var fname any = "hello world"
var sname interface{} = "hello world"
fmt.Println(fname)
fmt.Println(sname)
}
interface is a keyword
any is a builtin
any is defined as type any = interface{} which is a type alias and is in absolutely all ways equal to interface{}
so instead of using interface i can use any instead ?
instead of using an empty interface you can use any instead
you can't write:
type I any{
SomeMethod()
}
that does not work
interface - a keyword for defining interfaces
interface{} - an interface without any requirements, so all types implement it
any - a type alias of interface{} so same as interface{}
yeah i understand it now brother