cloudaice / learnGo

there are something about Go Useage
MIT License
0 stars 0 forks source link

类型为interface变量是否可以直接修改 #6

Open cloudaice opened 11 years ago

cloudaice commented 11 years ago

给interface类型的变量进行赋值之后,是否可以对该变量进行修改? 目前常见的从interface中获取数据方法如下:

switch val.(type) {
    case int:
        newval := val.(int)
        do something
}

没有看到在interface类型变量之上直接修改的用法