Rouge Documentation Help

Functionality provided by the language

There is certain functionality that is required in almost every codebase. It makes sense for the language to provide this functionality, so developers don't have to reimplement it in every program they write. This set of functionality that ships with the language is referred to as the standard library. In general, a library in programming is a collection functionality that can be re-used between multiple projects. The standard library is one such example, with the one difference that it is included with the language.

You have already been introduced to a small range of functions from the standard library: print, request_number, request_boolean, request_string. In this chapter, we are going to introduce you to further functions, methods, and types provided to you by Rouge's standard library. Like with the previously introduced functions, you can directly use the functions or types introduced in this chapter and don't have to somehow include them first.

Strings

Previously we learned how to create strings and how to embed other values in them. However, the type String provides various methods, extending its functionality. A selection of the most important methods is featured in the following. A complete list of all methods on the String type can be found in the reference. The reference chapter is a detailed list of all functions and types provided by the standard library.

length

Count the characters in the string.

Parameters:

  • this: String

Return type: Number

Example:

"Hello, World!".length()

Output:

13
concatenate

Combine two strings to form a new one.

Parameters:

  • this: String

  • other: String

Return type: String

Example:

"a".concat("b") // equivalent to "${"a"}${"b"}"
to_upper_case

Capitalize every letter in the string.

Parameters:

  • this: String

Return type: String

Example:

"Hello, World!".to_upper_case()

Output:

HELLO, WORLD!
to_lower_case

Transform every letter in the string to lowercase.

Parameters:

  • this: String

Return type: String

Example:

"Hello, World!".to_lower_case()

Output:

hello, world!
contains

Returns true in case the string contains a value.

Parameters:

  • this: String

  • value: String

Return type: Boolean

Example:

"Hello, World!".contains("Hello") "Hello, World!".contains("b")

Output:

true false
replace

Replaces every occurrence of a specified value with another.

Parameters:

  • this: String

  • previous_value: String

  • new_value: String

Return type: String

Example:

"Hello, World!".replace("World", "Steve")

Output:

Hello, Steve!

Numbers

Numbers also feature several methods, some of which are listed below. A complete account of all methods can also be found in the reference.

round_up

Round the number up to the next integer, in case it has any decimal places.

Parameters:

  • this: Number

Return type: Number

Example:

4.26.round_up() 4.round_up()

Output:

5 4
round_down

Round the number down to the next integer, in case it has any decimal places.

Parameters:

  • this: Number

Return type: Number

Example:

4.26.round_down() 4.round_down()

Output:

4 4
is_integer

Returns true if the number is an integer (whole number).

Parameters:

  • this: Number

Return type: Number

Example:

4.26.is_integer() 4.is_integer()

Output:

false true

Input/Output

You have already been introduced to multiple functions for requesting input from the user (request_number, request_boolean, request_string) as well as print for writing output to the screen. The standard library provides further functions for doing so, a selection of which is listed below.

print_inline

Writes a string to the screen but does not add a line break at the end.

Parameters:

  • value: String

Example:

print_inline("Hello, ") print("World!")

Output:

Hello, World!
read_line

Requests a String from the user, however, without a prompt.

The string ends when the user hits return.

Otherwise it works just like request_string.

Parameters: None

Return type: String

Example:

read_line()

Input:

Hello World

Output:

Hello
read_character

Requests a single character in the form of a String from the user without a prompt.

The user does not have to hit return, the character is captured directly when it is entered.

Parameters: None

Return type: String

Example:

read_character()

Input:

Hello

Output:

H
Last modified: 07 January 2026