local mySecretVariable = "A secret!"
local mySecretVariable2 = "Another secret."
function getTheSecret( firstSecret )
if ( firstSecret ) then
return mySecretVariable
else
return mySecretVariable2
end
end
print( getTheSecret() )
What should it print?
I think it would print "Another secret" because argument "firstSecret" is not given when the function is call out.
But in page where i found it it says it would print "A secret!"
If you run that instead in Lua, Love or an online compiler you wouldn't have to ask if u correct! And is not secure ask to us. We could always error or lie to you (as in that that webpage did) but a Lua interpreter won't. ;D
Last edited by coffee on Sun Sep 09, 2012 9:02 am, edited 1 time in total.
I've already made this mistake sometimes, so just to give you a warning:
Unlike many other programming languages (for example C++), Lua doesn't assume 0 to be false. There are only two values that Lua treats as a logical false, namely: false and nil. Every other value (even zero) is assumed to be true.
Happy coding
Did my comment help/offended you? Use the Karma button!! LÖVEing each day...