M
matt neuburg
p [1,2,3].insert(-1, "howdy")
#=> [1, 2, 3, "howdy"]
Docs: "Inserts the given values before the element with the given index
(which may be negative)."
The element with index -1 is 3, the last item. Before is before. I have
a feeling, though, that what's meant here is that when the index is
negative, before means after (perhaps because we're looking at the array
from the other end, as it were). Is that right?
m.
#=> [1, 2, 3, "howdy"]
Docs: "Inserts the given values before the element with the given index
(which may be negative)."
The element with index -1 is 3, the last item. Before is before. I have
a feeling, though, that what's meant here is that when the index is
negative, before means after (perhaps because we're looking at the array
from the other end, as it were). Is that right?
m.