Actually, I've since discovered there's a bug where you can just write the following, and Harlowe accepts it:
(set: $inventory to (a:"A","B","C")) (set: $inventory's 4th to "D") $inventory (= A,B,C,D)
This wasn't something I'd desired, but I think I might leave it in because it does have symmetry with the element retrieval and reassignment syntax. For appending to arrays, I guess it necessitates adding a "newlast", property index to accompany "last", so you can write (set: $a's newlast to "D").
You can also do this with datamaps (but not datasets, for obvious reasons):
(set: $inventory to (datamap: "Sword","Bronze")) (set: $inventory's Shield to "Iron") (print:$inventory's Shield) (= Iron)
Creating a newlast property index would make sense. I'm currently a bit bothered by the lack of a "push" analogue to go with "move from." I assume from the Harlowe documentation that "put into" would overwrite the entire array/dataset.
An example that looks reasonable, but will probably not do what a new user might expect
(set: $myFavoriteThings to (dataset:"raindrops","whiskers","kettles")) (put: "mittens" into $myFavoriteThings) (if: "mittens" is in $myFavoriteThings)[Mittens are among my favorite things!]
...Actually, right now, that example for some reason tells me that mittens is not defined when it tries to execute the "Put:" ... I'm not sure I understand how the "put:" macro works after all...
Comments
You can also do this with datamaps (but not datasets, for obvious reasons):
Creating a newlast property index would make sense. I'm currently a bit bothered by the lack of a "push" analogue to go with "move from." I assume from the Harlowe documentation that "put into" would overwrite the entire array/dataset.
An example that looks reasonable, but will probably not do what a new user might expect ...Actually, right now, that example for some reason tells me that mittens is not defined when it tries to execute the "Put:" ... I'm not sure I understand how the "put:" macro works after all...