Literals in the Rice


Literal is value that is directly described on the code.

For example,

int i = 2; // int literal

string s = "string literal"; // string literal

Literals generates an instance of the corresponding type at the memory and returns its address.

Literals behave in accordance with the rules of the type. This is because literals is instance. Thus, it is able to call the setter, getter, and method via a literal.

int len = "Length".Length; // It call the Length getter of the string type.

string s = 1000.ToString(); // It call the ToString() method of the int type.

For literal notation, please refer to the token.

For the behavior of literal, please refer to the corresponding type of the manual.

Copyright © Rice All rights reserved.