> For the complete documentation index, see [llms.txt](https://docs.csml.dev/language/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.csml.dev/language/standard-library/generic-methods.md).

# Generic methods

The following methods are common to all CSML primitive types.

### .type\_of()

Return the type of the target value (`string`, `array`, `object`, `float`, `boolean`, `int`, `null`)

```cpp
any_value.type_of() => String
```

### .to\_string()

Return the target value formatted as a string.

```cpp
any_value.to_string() => String
```

### .is\_number()

Check if a variable can be interpreted as a number (float or int)

```c
string.is_number() => boolean

// example
do var_int = "42"
say var_int.is_number() // true

do var_float = "42.42"
say var_int.is_number() // true

do obj = {"toto": "tutu"}
say obj.is_number() // false
```

### .is\_int()

Check if the variable can be interpreted as an int

```c
string.is_int() => boolean

// example
do var_int = "42"
say var_int.is_number() // true

do var_float = 42.42
say var_int.is_number() // false
```

### .is\_float()

Check if the variable can be interpreted as an float

```c
string.is_float() => boolean

// example
do var_int = 42
say var_int.is_number() // false

do var_float = 42.42
say var_int.is_number() // true
```

### .is\_error(), .get\_info()

Some functions may resolve to an error due to a faulty user input, an unreachable API, or some other bug in the code. You can check the result of such functions call (like `HTTP()` or `App())` with `.is_error()`, and get more information with `.get_info()`.

```c
  do x = HTTP("https://somewhere.com/does-not-exist").send()

  if (x.is_error()) {
    // get info a description of the error
    debug "{{x.get_info()}}"

    // try something else or ask again the user for input!
  }
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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, and the optional `goal` query parameter:

```
GET https://docs.csml.dev/language/standard-library/generic-methods.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
