var/mob/mob = M
Problem description: I'm reading through the blue-book but occasionally I will take some code from the resource. I found a code for admin-verbs and I found this odd little bit of code. An image of the full code should be below. Could somebody explain to me what the extra /mob is for?
GM_eradicate(atom/M // ...
All variables can be defined with a type, and that type determines what that variables and procs that the variable has access to.
In order to access the "key" variable of the chosen atom M, the variable must be typecasted into one of a type of object that has a key variable defined. Not all atoms have a "key" variable, so trying to access it would result in a compiler error.
If you typecast an object of a certain type as a variable of a different type, then you can get a runtime error by trying to access a variable or proc that the actual object doesn't have.
The safer way to typecast involves calling istype() before actually making the new variable that refers to it:
This way, you don't have an unsafe variable in the rest of the code.