isbasov

Ilya Basov

Feb 1st, 2021
163
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Go 0.28 KB | None | 0 0
  1. package main
  2.  
  3. import "fmt"
  4.  
  5. func main() {
  6.  
  7.     a := []string{"Ivan", "Oleg", "Dennis"}
  8.  
  9.     fmt.Println(join(",", a...))
  10. }
  11.  
  12. func join(sep string, l ...string) (res string) {
  13.  
  14.     for i, x := range l {
  15.  
  16.         res = res + x
  17.  
  18.         if i < len(l)-1 {
  19.             res = res + sep
  20.         }
  21.     }
  22.  
  23.     return
  24. }
  25.  
Advertisement
Add Comment
Please, Sign In to add comment