Skip to content

Commit c43409e

Browse files
authored
Merge pull request #57 from ferhatelmas/type-switch
refactor: simplify type switch
2 parents b699652 + 811d453 commit c43409e

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

operation.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -27,21 +27,21 @@ func calculate(arr interface{}, name string, operation rune) float64 {
2727
elem := redirectValue(value.Index(i)).Interface()
2828

2929
var value float64
30-
switch elem.(type) {
30+
switch e := elem.(type) {
3131
case int:
32-
value = float64(elem.(int))
32+
value = float64(e)
3333
case int8:
34-
value = float64(elem.(int8))
34+
value = float64(e)
3535
case int16:
36-
value = float64(elem.(int16))
36+
value = float64(e)
3737
case int32:
38-
value = float64(elem.(int32))
38+
value = float64(e)
3939
case int64:
40-
value = float64(elem.(int64))
40+
value = float64(e)
4141
case float32:
42-
value = float64(elem.(float32))
42+
value = float64(e)
4343
case float64:
44-
value = elem.(float64)
44+
value = e
4545
}
4646

4747
switch operation {

0 commit comments

Comments
 (0)