Ask AI
Skip to main content

Add to map

Function: Add to map

This action allows you to add a new item, or update an existing one, within a collection of key-value pairs, often referred to as a "map" or "dictionary." It's useful for organizing and managing structured data where each piece of information has a unique identifier (key) and an associated value.

Input,

  • Map: (MAP) - The collection of key-value pairs you want to modify. If you don't provide an existing map, a new empty map will be created for you.
  • Key: (STRING) - The unique name or identifier for the item you are adding or updating. This is a required input.
  • Value: (STRING) - The data you want to associate with the specified Key. This is a required input.

Output,

  • Result: (MAP) - The updated map, which now includes the new or modified key-value pair.

Execution Flow,

Real-Life Examples,

Example 1: Adding a new product to an inventory list

Imagine you have a list of products and their stock quantities. You want to add a new product.

  • Inputs:
    • Map: \{"Laptop": "10 units", "Mouse": "25 units"\}
    • Key: Keyboard
    • Value: 15 units
  • Result: The map \{"Laptop": "10 units", "Mouse": "25 units", "Keyboard": "15 units"\} is updated and available as 'Result'.

Example 2: Storing a user's preference for a new setting

You are managing user preferences and want to add a new setting for "dark mode."

  • Inputs:
    • Map: \{"notifications": "on", "language": "English"\}
    • Key: theme
    • Value: dark
  • Result: The map \{"notifications": "on", "language": "English", "theme": "dark"\} is updated and available as 'Result'.

Example 3: Updating contact information for a customer

You have a customer's contact details stored in a map and need to add their new phone number.

  • Inputs:
    • Map: \{"name": "Jane Doe", "email": "[email protected]"\}
    • Key: phone
    • Value: +1-555-123-4567
  • Result: The map \{"name": "Jane Doe", "email": "[email protected]", "phone": "+1-555-123-4567"\} is updated and available as 'Result'.