---
tags:
    - "Min"
    - "Lowest"
    - "Smallest"
    - "Least"
    - "List"
    - "Array"
---

# Minimum

[Collections](index.md) / **Minimum**

<div class="grid cards" markdown>

* :green_circle: Can Read

* :red_circle: Cannot Write

</div>

## Description

The smallest value found in a collection read as numbers

## Parameters

| Name | Description |
| :--- | :---------- |
| Collection | The collection whose smallest item is returned |

## Code

```cs
using System;
using UnityEngine;
using VisualScript.Icons;

namespace VisualScript.Runtime
{
    [Get]

    [Title("Minimum")]
    [Category("Collections/Minimum")]

    [Description("The smallest value found in a collection read as numbers")]
    [Image(typeof(IconStack), ColorTheme.Type.Teal, typeof(BadgeArrowDown))]

    [Parameter("Collection", "The collection whose smallest item is returned")]

    [Keywords("Min", "Lowest", "Smallest", "Least", "List", "Array")]

    [Serializable]
    public class TypeNumberCollectionMin : TypeNumber
    {
        [SerializeField] private GetCollection m_Collection = new GetCollection();

        public override double Get(Args args)
        {
            using Args scoped = Args.Get(args);

            int count = this.m_Collection.Capture(scoped);
            if (count == 0) return 0f;

            double min = 0f;
            bool hasValue = false;

            for (int i = 0; i < count; ++i)
            {
                if (!ArgsCollectionParameters.TryGetItem(this.m_Collection, scoped, i, out double item)) continue;

                min = hasValue ? Math.Min(min, item) : item;
                hasValue = true;
            }

            return min;
        }

        public override string ToString()
        {
            return $"Min of {this.m_Collection}";
        }

        protected override SubscriptionMode Subscription => SubscriptionMode.OnChange;
    }
}

```

