Skip to content

Commit

Permalink
Merge pull request #57 from ferhatelmas/type-switch
Browse files Browse the repository at this point in the history
refactor: simplify type switch
  • Loading branch information
thoas committed Apr 7, 2019
2 parents b699652 + 811d453 commit c43409e
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions operation.go
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 c43409e

Please sign in to comment.