# Multiple ways to interpret an argument

By getting the amount of values with `reader.Length`, we can support multiple ways to interpret an argument. An example would be how a `UnityEngine.Color` can be interpreted both from a hex value and an RGB value.

```cs
[Converter]
public static Color ColorConverter(ArgumentReader reader)
{
    float r, g, b, a;

    switch (reader.Length)
    {
        // In case the amount of components was 1
        case 1:
            if (reader.IsNumeric())
            {
                // If the component is a number, return an RGB color with this value
                float value = reader.Read<float>() / 255;
                return new(value, value, value);
            }
            else
            {
                // If the component can be read as a string, try to return a color based on a hex value
                string hex = reader.Read<string>();
                if (ColorUtility.TryParseHtmlString(hex, out Color hexColor))
                    return hexColor;
                else
                    throw new Exception($"Invalid hex value: '{hex}'.");
            }

        // In case the amount of components was 3
        case 3:
            // Return an RGB value using the 3 numbers
            r = reader.Read<float>();
            g = reader.Read<float>();
            b = reader.Read<float>();
            return new(r, g, b);

        // In case the amount of components was 4
        case 4:
            // Return an RGBA value using the 4 numbers
            r = reader.Read<float>();
            g = reader.Read<float>();
            b = reader.Read<float>();
            a = reader.Read<float>();
            return new(r, g, b, a);
    }

    // If more or less components was provided, we notify of the error
    throw new Exception($"Could not retrieve color from input: {reader.Source}.");
}
```

{% hint style="info" %}
**Note**

This converter is built-in, and is purely used as an example. You wouldn't need to create this in order to support parameters of type `UnityEngine.Color`.
{% endhint %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.pentafloat.com/documentation/converters/multiple-ways-to-interpret-an-argument.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
