ID:260673
 
Well, currently if we check something in an associated list, it'll return the value associated to it.. Like:

var/list/L = list(":P"=":D","S"="G")
L[":P"] // would return :D
//and
L["S"] // would return G


My feature request is, that if the list isn't an associative list, when you check the value like specified up ^ it would return the index, like so:

    
var/list/A = list("phew","phoey")
world << A["phew"] // would output 1 as 1 is the index of "phew"

var/D = "phoey" // sets D to "phoey"
world << A[D] // would output 2 as 2 is the index of "phoey"


I believe this would be a much easier way to find the index without actually calling Find() though it may be an useless and probably unwanted request, I thought I'd throw it out there to see what people think.
This isn't really workable, because, by default, L["phew"] would be null. What if I want it to be null, and the compiler says, "No, this is #1 in the list, it is associated with 1." The possible, but minor, speed gain wouldn't be worth destroying compatibility with older code.
But this is exactly what the Find() proc is for.
Well... just because you thought it worked this way doesn't mean it should. >_>

Andre-g1 wrote:
I believe this would be a much easier way to find the index [...]

How is it much easier? It isn't any easier, other than the fact it'd save you typing a few characters, which is of course not a reason for a new feature. Implementing it like you want also makes things less easy in fact since you'd have 2 different uses for the same operator (list-wise), and it would also break the ability to check if an element has an associated value or not.

though it may be an useless and probably unwanted request

"Pointless" is probably the word. Why have the BYOND Staff spend time on implementing a feature essentially already in?
Absolutely not. We need the behavior we are currently given because otherwise, there would be too many inconsistencies and errors in handling data.