1.11. Data literals

Golo supports a set of data literals. They directly map to their counterparts from the Java Standard API. We give them along with examples in the data literals table below.

Java type Golo literals

null

null

java.lang.Boolean

true or false

java.lang.String

"hello world"

java.lang.Character

'a', 'b', …

java.lang.Integer

123, -123, 1_234, …

java.lang.Long

123_L, -123_L, 1_234_L, …

java.lang.Double

1.234, -1.234, 1.234e9, …

java.lang.Float

1.234_F, -1.234_F, 1.234e9_F, …

java.lang.Class

String.class, java.lang.String.class, gololang.Predef.module, …

java.lang.invoke.MethodHandle

^foo, ^some.module::foo, …

Speaking of strings, Golo also supports multi-line strings using the """ delimiters, as in:

let text = """This is
a multi-line string.
  How
    cool
      is
        that?"""

println(text)

This snippet would print the following to the standard console output:

This is
a multi-line string.
  How
    cool
      is
        that?