Associative array/Merging: Difference between revisions

Add SenseTalk implementation
No edit summary
(Add SenseTalk implementation)
Line 1,440:
"price": "15.25",
}</pre>
 
=={{header|SenseTalk}}==
In addition to setting individual property values, SenseTalk includes 5 built-in operations for modifying property lists, to: add properties, replace properties, remove properties, retain properties, and rename properties. The operation to replace properties is needed for this task.
<lang sensetalk>set base to {name:"Rocket Skates", price:12.75, color:"yellow"}
 
set update to {price:15.25, color:"red", year:1974}
 
put "Base data: " & base
put "Update data: " & update
 
// replacing as an operator, to generate merged data on the fly:
put "Merged data: " & base replacing properties in update
 
// replace as a command, to modify base data in place:
replace properties of update in base
put "Base after update: " & base
</lang>
{{out}}
<pre>
Base data: {color:"yellow", name:"Rocket Skates", price:12.75}
Update data: {color:"red", price:15.25, year:1974}
Merged data: {color:"red", name:"Rocket Skates", price:15.25, year:1974}
Base after update: {color:"red", name:"Rocket Skates", price:15.25, year:1974}
</pre>
 
=={{header|Smalltalk}}==