Advertisement
cwchen

[Go] Functions with multiple returning values.

Sep 30th, 2017
858
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Go 0.25 KB | None | 0 0
  1. package main
  2.  
  3. import (
  4.     "log"
  5. )
  6.  
  7. func divmod(a int, b int) (int, int) {
  8.     return a / b, a % b
  9. }
  10.  
  11. func main() {
  12.     m, n := divmod(5, 3)
  13.  
  14.     if !(m == 1) {
  15.         log.Fatal("Wrong value m")
  16.     }
  17.  
  18.     if !(n == 2) {
  19.         log.Fatal("Wrong value n")
  20.     }
  21. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement