
Originally Posted by
dlsmd
if your talking eval as checking to see if code works
I'm not. In most scripting languages nowadays there's an eval() function that takes a string and parses it as code. In Ruby, for example,
Code:
instructions = "5.times print 'odelay! '"
eval(instructions)
would yield:
Code:
odelay! odelay! odelay! odelay! odelay!
I'd still like to have it, since I could reduce job_state_change to one line and a table lookup if I did, but I can make do with if-chains.
The eval addon doesn't do what I'm talking about either, as far as I know, and I'm pretty sure it can't see GearSwap's variables.
"Switch-case" has nothing to do with upper- or lower-case letters, either. In most languages, instead of doing:
Code:
if fu == "bar" then
print("Fucked up beyond all recognition, sir!")
elseif fu == "sna" then
print("Situation normal--all fucked up, sir!")
elseif fu == "kung" then
print("That cat was fast as lightning, sir!")
else
print("I don't have a joke for this one, sir!")
end
you can just do (another Ruby example--Python inexplicably doesn't have one either)
Code:
case fu
when "bar"
print("Fucked up beyond all recognition, sir!")
when "sna"
print("Situation normal--all fucked up, sir!")
when "kung"
print("That cat was fast as lightning, sir!")
else
print("I don't have a joke for this one, sir!")
end
You may think these are the same, except with if-elseif chains, you're testing the same condition multiple times, which reduces performance dramatically--especially if you perform further tests inside. With a switch-case, you test the same condition exactly once.
Bro, do you even code?