ID:161815
 
Ok I'm pretty sure I'm not using the best way to do this and I'm getting a little tired of typing this in my code all the time.

But lets say you have a proc that teaches someone a skill, but only if they dont already have it, as demonstrated (badly) in the below code:
obj/Skill/Jump
mob/proc/Learn()
for(var/obj/Skill/Jump/A in contents) return
contents+=new/obj/Skill/Jump
src<<"You learned Jump"

I tried this too but it didnt work
for(!var/obj/Skill/Jump/A in contents) contents+=new/obj/Skill/Jump

But I really didn't expect it to work.

Can anyone tell me a better way to see if something is NOT in your contents and if not add that thing to your contents?

And what about:
if(!contents.Find(/obj/Skill/Jump)) contents+=new/obj/Skill/Jump
?
1) Learn about the operational standing (that is, what operators have more priority)...

See [link] for an example of how not knowing them can do >_>

2) Maybe you want to locate(/path) in Ref.contents?
if(!(locate(X) in Y.contents)) Z.Move(Y)
if(!(locate(X) in Y)) Y.contents += Z

locate() returns only a single object reference, but in this case, that's alright since we only want one type.
In response to GhostAnime
So that brings me to another question.

Saying "in something" does the same thing (functionally) as "in something.contents"?
In response to Dragonn
When you check 'in' an object, you are checking its contents (useful shortcut, neh?).

Of course that is if it is a datum or a variant of /atom (including /mob and the other hierarchy branches). For /list, it checks through the entries:
if(!(X in list(A,B,C))) CRASH("How come 'X' is not 'A', 'B' or 'C'?!")
Why would that not work? it looks like it will work just fine
In response to Lt. Pain
He is basically looking for (0 or 1) in X.contents, due to the higher operational standing ! has (note the ID that I placed in the my post here earlier to see how one person had problems with it).

Though I am not sure how exactly it would affect it in for() (other than you are looking for a numerical value) and right before a variable...