Skip to content

Commit 54e885c

Browse files
committed
Improve code readability
1 parent 37417ac commit 54e885c

File tree

1 file changed

+3
-6
lines changed

1 file changed

+3
-6
lines changed

vm/runtime.go

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,7 @@ func fetch(from interface{}, i interface{}) interface{} {
2929
switch kind {
3030

3131
case reflect.Array, reflect.Slice, reflect.String:
32-
index := toInt(i)
33-
value := v.Index(int(index))
32+
value := v.Index(toInt(i))
3433
if value.IsValid() && value.CanInterface() {
3534
return value.Interface()
3635
}
@@ -46,11 +45,9 @@ func fetch(from interface{}, i interface{}) interface{} {
4645
if value.IsValid() && value.CanInterface() {
4746
return value.Interface()
4847
}
49-
50-
case reflect.Func:
51-
panic(fmt.Sprintf("cannot fetch %v from %T", i, from))
5248
}
53-
return nil
49+
50+
panic(fmt.Sprintf("cannot fetch %v from %T", i, from))
5451
}
5552

5653
func slice(array, from, to interface{}) interface{} {

0 commit comments

Comments
 (0)