Skip to content

Commit

Permalink
refactor: simplify type switch
Browse files Browse the repository at this point in the history
  • Loading branch information
ferhatelmas committed Apr 7, 2019
1 parent b699652 commit 811d453
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions operation.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,21 +27,21 @@ func calculate(arr interface{}, name string, operation rune) float64 {
elem := redirectValue(value.Index(i)).Interface()

var value float64
switch elem.(type) {
switch e := elem.(type) {
case int:
value = float64(elem.(int))
value = float64(e)
case int8:
value = float64(elem.(int8))
value = float64(e)
case int16:
value = float64(elem.(int16))
value = float64(e)
case int32:
value = float64(elem.(int32))
value = float64(e)
case int64:
value = float64(elem.(int64))
value = float64(e)
case float32:
value = float64(elem.(float32))
value = float64(e)
case float64:
value = elem.(float64)
value = e
}

switch operation {
Expand Down

0 comments on commit 811d453

Please sign in to comment.