I didn't even realize kikito posted his own. Ignore mine. It sucks.
Anyway, what does def do versus function? And is there any benefit to using an underscore _ in the for loop?
Having trouble getting a program running
- bartbes
- Sex machine
- Posts: 4946
- Joined: Fri Aug 29, 2008 10:35 am
- Location: The Netherlands
- Contact:
Re: Having trouble getting a program running
def vs function, well def doesn't exist.
_ vs i/k, no difference, but it tells people reading your source that you're not using it. (some languages actually see _ as an ignore keyword)
_ vs i/k, no difference, but it tells people reading your source that you're not using it. (some languages actually see _ as an ignore keyword)
- Jasoco
- Inner party member
- Posts: 3727
- Joined: Mon Jun 22, 2009 9:35 am
- Location: Pennsylvania, USA
- Contact:
Re: Having trouble getting a program running
Oh, then why does kikito's code have def instead? Is that not valid code?
- bartbes
- Sex machine
- Posts: 4946
- Joined: Fri Aug 29, 2008 10:35 am
- Location: The Netherlands
- Contact:
Re: Having trouble getting a program running
It is not.
- Robin
- The Omniscient
- Posts: 6506
- Joined: Fri Feb 20, 2009 4:29 pm
- Location: The Netherlands
- Contact:
Re: Having trouble getting a program running
To clarify: def is in Python or Ruby what is function in Lua. I take it kikito was mistaken with one of those.
Help us help you: attach a .love.
- Jasoco
- Inner party member
- Posts: 3727
- Joined: Mon Jun 22, 2009 9:35 am
- Location: Pennsylvania, USA
- Contact:
Re: Having trouble getting a program running
Oh. Good. Darn, I thought it was some new way of doing things I didn't know about.
Why can't all languages be the same? lol
Why can't all languages be the same? lol
- bartbes
- Sex machine
- Posts: 4946
- Joined: Fri Aug 29, 2008 10:35 am
- Location: The Netherlands
- Contact:
Re: Having trouble getting a program running
Because then they'd all suck.
- Robin
- The Omniscient
- Posts: 6506
- Joined: Fri Feb 20, 2009 4:29 pm
- Location: The Netherlands
- Contact:
Re: Having trouble getting a program running
... and you'd end up with PHP.
Help us help you: attach a .love.
Re: Having trouble getting a program running
The point of having different programming languages is so that they are different and better then each other. Personally, I wish there were less. I've learned 20 programming languages (at least), and I still haven't found the perfect one. Thus, I'm creating my own VM, etc., but that's besides the point.
So, _ tells programmers that it is ignored. That's pretty simple. It would be nice if Lua took that as a "black hole" and deleted anything sent to it (like on Linux when you redirect console output to /dev/null).
So, _ tells programmers that it is ignored. That's pretty simple. It would be nice if Lua took that as a "black hole" and deleted anything sent to it (like on Linux when you redirect console output to /dev/null).
Good bye.
Re: Having trouble getting a program running
Luiji wrote:It would be nice if Lua took that as a "black hole" and deleted anything sent to it (like on Linux when you redirect console output to /dev/null).
Code: Select all
setmetatable(_G, {__newindex = function(table, key, value)
if key:sub(1,1) ~= "_" then
rawset(table, key, value)
end
return
end})
Who is online
Users browsing this forum: No registered users and 5 guests