-
-
Save coolbrg/6e2d028e926fb1bb9082 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import "log" | |
func alterValue(val interface{}) { | |
INCR := 10 | |
switch i := val.(type) { | |
case nil: | |
log.Println("Nil value") | |
case int: | |
log.Println(i + INCR) | |
case float64: | |
log.Println(i + float64(INCR)) | |
default: | |
log.Println("Unknown Value") | |
} | |
} | |
func main() { | |
intVal := 10 | |
floatVal := 10.4 | |
alterValue(intVal) | |
alterValue(floatVal) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment