generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripters
Home Search
 

What is this?

Previous Thread :: Next Thread 
EliteDerper is not online. EliteDerper
Joined: 05 Feb 2012
Total Posts: 2288
31 Jul 2014 06:05 AM
I dont see anything about on the wiki.
What does: " for _, " do?
Report Abuse
Fluffmiceter is not online. Fluffmiceter
Joined: 28 Jan 2012
Total Posts: 6931
31 Jul 2014 06:17 AM
LIES

how dare you disgrace the roblox wiki!
look up "for loops"
Report Abuse
Oysi is not online. Oysi
Joined: 06 Jul 2009
Total Posts: 9058
31 Jul 2014 06:51 AM
"for _," doesn't do anything. What you're referring to is the generic for loop:

  for i, v in pairs(t) do end

And "_" is a valid parameter (variable) name, there for you can do something like:

  for _, v in pairs(t) do end

Or:

  for i, _ in pairs(t) do end

OR EVEN:

  for _, _, _, _, _, _ in pairs(t) do end -- magic

OR EVEN:

  for _,_,_,_,_,_ in _,_,_,_,_,_ do end

That is valid Lua code. It will compile. However, it will error once ran. To prevent that, you can add this right above it:

  function _() end

Also, I should note that this is not the only use of the generic for loop, pairs returns an iterator, and you can use your own iterators. For example:

  function iterator()
    return "potato", "cow", "cake"
  end

  for a, b, c in iterator do print(a, b, c) end

That will repeatedly print potato cow cake. And you can pass along your own arguments to the iterator, which lets you do some interesting things:

  function iterator(wisdom, morewisdom)
    return morewisdom .. wisdom
  end

  for wisdom in iterator, "potato", "starterwisdom" do print(wisdom) end

Of course, this isn't really how you would want to build your iterators, but I'm just showing you the possibilities. =O
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image