Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6237811
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T11:05:58+00:00 2026-05-24T11:05:58+00:00

I encountered the following code in a project that I’m working with. i don’t

  • 0

I encountered the following code in a project that I’m working with. i don’t understand the iteration part of for-loop. What is the select() function?

function _log (str,...)
  local LOG="/tmp/log.web"
  for i=1,select('#',...) do
    str= str.."\t"..tostring( select(i,...) )
  end
os.execute("echo \"".. str .."\" \>\> " .. LOG )
end
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T11:05:59+00:00Added an answer on May 24, 2026 at 11:05 am

    From the Lua manual:

    If index is a number, returns all arguments after argument number index. Otherwise, index must be the string "#", and select returns the total number of extra arguments it received.

    From this post on Lua’s multiple arguments and the "select" function, you can convert into a table if you really need to:

    function multiple_args(...)
      local arguments = {...}  -- pack the arguments in a table
      -- do something --
      return unpack(arguments) -- return multiple arguments from a table (unpack)
    end
    

    Finally, if you pass "#" as index, the function returns a count of the multiple arguments provided:

    print(select("#")) --> 0
    print(select("#", {1, 2, 3})) --> 1 (single table as argument)
    print(select("#", 1, 2, 3)) --> 3
    print(select("#", {1,2,3}, 4, 5, {6,7,8}) --> 4 (a table, 2 numbers, another table)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm reading the source code of an open-source project and I've encountered the following
I am debugging some code and have encountered the following SQL query (simplified version):
We've encountered the following issue. I like to use the following writing: SELECT Id,
I encountered a problem when running some old code that was handed down to
This is the first time I am working for a front-end project that requires
I encountered the following construct in various places throughout Ocaml project I'm reading the
I am working on porting code from JAVA to C#, and part of the
In a groovy tutorial, I encountered the following code: class DateTagLib { def thisYear
While converting an old code, I encountered the following problem. Given an HTML string,
I encountered the following ddl in a pl/sql script this morning: create index genuser.idx$$_0bdd0011

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.