View Full Version : [Core] small letters in the source code?
Maspalio
October 5th, 2016, 17:04
Hi,
Another question if someone around knows. What means the unique letters in words like bSecretRoll, sType, aDice, rRoll, aAddMod, nMod?
I Mean, what does "s", "a", "b", "n" letters refers to? Is it a plain arbitrary choice or is it a meaning to them?
Thanks a lot.
Moon Wizard
October 5th, 2016, 17:42
It's a notation called camel case that is used by some programmers to denote the "data type" of a variable without having to look up the definition. Lua is a loosely typed language, so any variable can have any type. However, in this case, the programmer has included these prefixes to give a hint about what data type is expected.
b = boolean
n = number
s = string
a = table (or array)
v = variable (unknown or variable data type)
Regards,
JPG
Maspalio
October 5th, 2016, 19:17
Very helpful, thanks.
phantomwhale
October 8th, 2016, 13:13
Known in computer science as Hungarian Notation - https://en.wikipedia.org/wiki/Hungarian_notation
dulux-oz
October 8th, 2016, 14:09
It's actually a very "good" style or practice to use - and is generally a sign of a professional coder versus an amateur.
It also helps in the practice of "self-documenting code'", another very good habit to get into.
Powered by vBulletin® Version 4.2.1 Copyright © 2024 vBulletin Solutions, Inc. All rights reserved.