Learn Lua in Neovim: Multiple Returns and Variadics — return a, b and ... | Episode 13
3views
0010:32
T
Taught by Celeste AI - AI Coding Coach
View on YouTubeDescription
Lua functions can return more than one value — and accept any number of arguments! In this episode we return
multiple values, discard unwanted ones with _, and write variadic functions using ... and select() to build a
flexible sum function.
Every keystroke is shown on screen with 3-second pauses so you can follow along at your own pace.
Source code:
https://github.com/GoCelesteAI/learn-lua-in-neovim
What You'll Learn:
- return a, b — returning multiple values at once
- Capturing multiple returns: local x, y = func()
- _ — the discard convention for unused return values
- ... — variadic parameter (any number of arguments)
- select("#", ...) — count of variadic arguments
- Building a sum(...) function that accepts any count
Timestamps:
0:00 Intro
0:12 Preview
0:44 Multiple Returns — min_max function
2:50 Run: Min and Max output
3:04 Divide — quotient and remainder
4:39 Discard with _ underscore
5:20 Run: Divide and Discard output
5:33 Variadic Sum with ... and select()
8:37 Run: Final output
8:50 Code review
9:00 Recap
Key Takeaways:
1. return a, b returns multiple values in one call
2. local x, y = func() captures both return values
3. _ is the convention for discarding a return value
4. ... in parameters accepts any number of arguments
5. select("#", ...) counts the variadic arguments
This is Episode 13 of the Learn Lua in Neovim series. New episodes cover scope, functions as values, closures,
and more — all coded inside Neovim.
Taught by CelesteAI. Like & subscribe for more tutorials!
#lua #neovim #programming #tutorial #beginners #learnlua #luaprogramming #neovimtutorial #luamultiplereturns
#luavariadic #coding
---
Tags: lua, lua tutorial, learn lua, lua multiple return values, lua variadic, lua variadics, lua return
multiple, lua discard, lua underscore, lua select, lua ellipsis, lua dot dot dot, lua function returns, lua
flexible functions, lua for beginners, neovim lua, neovim tutorial, learn lua in neovim, lua episode 13,
programming tutorial, coding tutorial, beginner programming, lua 2026, neovim 2026, screenkey, code along, lua
basics, lua advanced functions
Tags
lualua tutoriallearn lualua multiple return valueslua variadiclua variadicslua return multiplelua discardlua underscorelua selectlua ellipsislua dot dot dotlua function returnslua flexible functionslua for beginners