Jul 04, 2016; 18:55
Jolle Carlestam
Array Pop Push and Top
While digging in the json_decode code I found out that there are some method calls to the array type that are not documented.
Namely
array -> pop
array -> push
and
array -> top
Please experiment with them and see how they can fit into your work flow.
Since wayback I’ve had my own implementations of pop and push (jc_pop and jc_push). Admittedly not my own idea. The code has a comment about me stealing it from Göran. But still.
Array -> pop does in fact use the exact same technique as jc_pop. Array -> push on the other hand uses a different approach than array -> jc_push. I like mine better and am going to keep it around. Jc_pop is ditched. No point in having the exact same things done by different methods.
Array -> top was news to me. Although it really doesn’t add anything that wasn’t easy to do before. It is in reality an alias to array -> last. I suppose the reason to add it was because similar calls are possible in other languages.
Anyway. There’s no trace of array -> pop, push or top in the documentation. Neither Lasso guide nor Lasso reference.
Would be nice to have them mentioned.
BTW
Here’s my version of push:
define array -> jc_push(...elements) => {
#elements?
with e in #elements do .insert(#e)
return .size
} // I probably did not write this myself. It’s not my coding style.
Lassos default array -> push allows you to push one item to the array and returns the pushed item.
HDB
Jolle
#############################################################
This message is sent to you because you are subscribed to
the mailing list Lasso Lasso@lists.lassosoft.com
Official list archives available at http://www.lassotalk.com
To unsubscribe, E-mail to: <Lasso-unsubscribe@lists.lassosoft.com>
Send administrative queries to <Lasso-request@lists.lassosoft.com>