The Spread Operator (or Variadic Functions) in Golang

Поделиться
HTML-код
  • Опубликовано: 12 дек 2024

Комментарии • 4

  • @oskar1504
    @oskar1504 5 месяцев назад

    Nice to see that go lang also has a spread operator and the n parameter functionality. BUT couldnt I just pass the slice as slice or arr parameter like "func sum arr []int) {". Why should i use the spread syntax and not just use the arr as parameter.

    • @FloWoelki
      @FloWoelki  5 месяцев назад

      Yes, you are right. I've actually explained this in the video.
      Generally, it's more convenient and readable for other developers, I think that is pretty clear. Also, it avoids creating unnecessary slices for each function call. That's especially useful for performance-critical code.
      I hope that makes sense :)

  • @bayinoyi
    @bayinoyi 5 месяцев назад

    Great video, but brother please, bestow me with that font name, it looks gorgeous!

    • @FloWoelki
      @FloWoelki  4 месяца назад +1

      Thank you for the question. I do use the font Monaspace :)