ID:2411099
 
Applies to:
Status: Open

Issue hasn't been assigned a status value.
// imagine having a list that your code accesses heavily...
// but there's no guarantee said list is always initialized.
mob/var/somelist[]

// currently, everywhere you access the list has to be written as:
somelist && somelist[index]

// my suggestion would shorten this to:
somelist?[index]


...Normally I'd create a proc for the sake of sanity checking, but that becomes non-viable when you have many frequently used lists. For now I've resorted to always having the lists initialized, but I figured I'd toss this suggestion out there.
+

var/i
if(somelist && (i = somelist[index]))


is a pattern I type pretty much constantly.
Also +1 from me, I pretty much do exactly what Ter does all over the place.
. already works for lists, like so:
var/list/foo = list("bar")
world.log << foo.[1]


this prints out "bar"

?. is however an error:

expected var or proc name after ?. operator
I'd have liked to have this frequently in the past
Bump.
Aye

Login to reply.