mob/var
list/A_List = list("One" = /obj/Bob)
...or can it only be done with numbers?
ID:151841
Jan 10 2009, 3:38 am
|
|
So wait... on an associative list could I do something like this...
mob/var ...or can it only be done with numbers? |
You could completely cut out the associative part and just use an index if you're using increments of 1.
var/list/L = list(/obj/Bob,/obj/Joe,/obj/Harry) Note that this will not work, however: var/list/L = list(1 = /obj/Bob, 3 = /obj/Joe) //you cannot directly associate anything to a number |
The key (item/element in the list) and its associated value can generally be any type of value (text strings, numbers, type path, object reference...), however the exception is that the key can't be a number. This is because using a numeric index to access an item in the list already has a different purpose (it returns the element in that position, so L[3] returns the 3rd item in L). The associated value can be a number however, and the key could be a text string containing a number.