BlueHound
|
  |
| Joined: 30 Jan 2012 |
| Total Posts: 1971 |
|
|
| 19 May 2013 08:51 PM |
I've noticed scripts with end) with the ')' why is that there? |
|
|
| Report Abuse |
|
|
| |
|
Voidion
|
  |
| Joined: 01 Aug 2011 |
| Total Posts: 2668 |
|
|
| 19 May 2013 09:12 PM |
| They're used to end anonymous functions. |
|
|
| Report Abuse |
|
|
|
| 19 May 2013 09:14 PM |
Most of the time, they use it to close a connection thingy:
Event:connect(--open function() --stuff end)--close |
|
|
| Report Abuse |
|
|
Zkiller11
|
  |
| Joined: 25 Aug 2009 |
| Total Posts: 2914 |
|
|
| 19 May 2013 09:15 PM |
The parenthesis is to close an anonymous function. For example,
a basic function, per se, might look like this:
function onTouch() --Code end script.Parent.Touched:connect(onTouch)
an anonymous looks like this:
script.Parent.Touched:connect(function() --Code end)
It more or less eliminates the need for a connection line, and supposedly speeds up the code. I'm not quite sure if it does or does not speed up the code, though. Long story short, it contains the code pertaining to the anonymous function, specified earlier in the coding.
|
|
|
| Report Abuse |
|
|
miz656
|
  |
| Joined: 19 Jul 2010 |
| Total Posts: 15336 |
|
|
| 19 May 2013 09:43 PM |
" I'm not quite sure if it does or does not speed up the code"
It really doesn't. People who program in RBX.Lua do it mainly because they already added the connection line in the beginning of the program; so they don't have to add it at the end.
People who program in Lua use anonymous functions for functions that have very little code in them.
ex:
(function(parameter) print(parameter); end)("hi")
|
|
|
| Report Abuse |
|
|
Zkiller11
|
  |
| Joined: 25 Aug 2009 |
| Total Posts: 2914 |
|
|
| 19 May 2013 09:59 PM |
| I didn't think it did. That was just something I heard, and I figured I might as well throw it in there. I wasn't sure, so I tried to make sure mis-information wasn't going to be spreaded by stating "I wasn't sure." :P |
|
|
| Report Abuse |
|
|
Usering
|
  |
| Joined: 18 Aug 2012 |
| Total Posts: 10281 |
|
|
| 19 May 2013 10:34 PM |
"When you write functions the wrong way you have to put it there use this instead"
The wrong way? It is actually the best way to use functions in which you are connecting. |
|
|
| Report Abuse |
|
|
btft
|
  |
| Joined: 19 Feb 2011 |
| Total Posts: 1512 |
|
| |
|
| |
|
dave2011
|
  |
| Joined: 02 Oct 2010 |
| Total Posts: 10581 |
|
|
| 20 May 2013 12:46 AM |
| actually connection lines confuse me a lot more than anonymis functions lol |
|
|
| Report Abuse |
|
|
loleris
|
  |
| Joined: 23 Feb 2009 |
| Total Posts: 1610 |
|
|
| 20 May 2013 01:33 AM |
@BlueHound
BECAUSE WE CANNN!!! MUAHAHAHAH |
|
|
| Report Abuse |
|
|
BlueHound
|
  |
| Joined: 30 Jan 2012 |
| Total Posts: 1971 |
|
|
| 20 May 2013 01:58 AM |
| Thanks everyone that replied :D |
|
|
| Report Abuse |
|
|
Usering
|
  |
| Joined: 18 Aug 2012 |
| Total Posts: 10281 |
|
|
| 21 May 2013 11:39 PM |
@Architect,
I never said there was, I'm just saying that way works just as good. If not, better.
Life is an endless nightmare |
|
|
| Report Abuse |
|
|
|
| 22 May 2013 05:06 AM |
when i just started scipting like a month ago i thought annonymous functions where useless too but i wouldnt say that now
now i use them sometimes |
|
|
| Report Abuse |
|
|