3 ms·
It actually is once you strip all the bash-isms. Here's what this code is really doing. def append(ARRAYNAME, VALUE): # Store the length of the array as
by Spivak 8y ago
It actually is once you strip all the bash-isms. Here's what this code is really doing.
def append(ARRAYNAME, VALUE):
# Store the length of the array as a variable ARRAYNAME_LEN
# Store the values of the array as variables ARRAYNAME_0, ARRAYNAME_1,...
len = globals.get('{{ ARRAYNAME }}_LEN') || 0
len += 1
# Update the length.
globals.set('{{ ARRAYNAME }}_LEN', len)
# Add the value.
globals.set('{{ ARRAYNAME }}_{{ len }}', VALUE)
return
Nobody said that bash has pretty syntax but this kind of thing wont even phase you once you're used to all the escaping and bracket substitution rules.