Advertisement
cwchen

[Go] Functions with returning values.

Sep 30th, 2017
855
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Go 0.21 KB | None | 0 0
  1. package main
  2.  
  3. import (
  4.     "log"
  5.     "math"
  6. )
  7.  
  8. func add(a float64, b float64) float64 {
  9.     return a + b
  10. }
  11.  
  12. func main() {
  13.     if !(math.Abs(add(3, 2)-5.0) < (1.0 / 1000000)) {
  14.         log.Fatal("Wrong value")
  15.     }
  16. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement