ddonche/goblin-lang
0.46.24
1
0
docs reference
[[update-last]]

Update_last


Update Last replaces the last value in a collection.


Overview

update_last replaces the last value in a collection.

items | [1, 2, 3]

:update_last!(items, 99)
items | [1, 2, 3]

:update_last!(items, 99)

Result:

[1, 2, 99]
[1, 2, 99]


Mutation

Like most collection utilities, update_last follows Goblin's bang (!) rules.

  • :update_last returns a modified copy
  • :update_last! mutates the original collection

Similar Operations In Other Languages

JavaScript Python Java C# Ruby PHP
assignment assignment set() assignment []= assignment
splice() slice assignment replaceAll() Replace() replace array_replace()
fill() list comprehension update loop Select() map! array_map()