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

Update_first


Update First replaces the first value in a collection.


Overview

update_first replaces the first value in a collection.

items | [1, 2, 3]

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

:update_first!(items, 99)

Result:

[99, 2, 3]
[99, 2, 3]


Mutation

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

  • :update_first returns a modified copy
  • :update_first! 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()