Stenway Developer Network

Primitive Types

Integer

64-bit integer (from -9,223,372,036,854,775,808 to 9,223,372,036,854,775,807)

Decimal literal

i1 int = 0
i2 int = 1234
i3 int = 0000123434
i4 int = 123_456_789

Hexadecimal literal

hex1 int = 0xFF
hex2 int = 0XaA001234
hex3 int = 0x01234567_89ABCDEF

Binary literal

bin1 int = 0b00001001
bin2 int = 0B11111111
bin3 int = 0b01000100_00101010_11110000

Class / default value 0:

i1 int
i2 int = new Int()

Floating-Point Number

64-bit floating point

f1 float = 0.5
f2 float = 123.4
f3 float = 123.4e5
f4 float = 123.4e-5

Class / default value 0.0:

f1 float
f2 float = new Float()

Boolean

bool

b1 bool = true
b2 bool = false
b3 bool = TRUE
b4 bool = False

Class / default value false:

b1 bool
b2 bool = new Bool()

Characters

char (4 Byte) - U+0000 .. U+D7FF and U+E000 U+10FFFF - Unicode scalar

c1 char = 'a'
c2 char = '\0'
c3 char = '\\'
c4 char = '\''
c5 char = '\n'
c6 char = '\N'
c7 char = '\xFF'
c8 char = '\u000061'
c9 char = '\u020007'
c10 char = '\U020007'

Class / default value 0:

c1 char
c2 char = new Char()

Strings

String

s1 string = ""
s2 string = "Hello world"
s3 string = "Hello\nworld"
s4 string = "It cost me $10."
s5 string = "c:\\Temp\\Readme.txt"
s6 string = "<element attribute=\"value\">Text</element>"

Escape sequences

s1 string = "\0"
s2 string = "\\"
s3 string = "\""
s4 string = "\n"
s5 string = "\N"
s6 string = "\t"
s7 string = "\xFF"
s8 string = "\u000061"
s9 string = "\U020007"

Class / default value empty string:

s1 string
s2 string = new String()

Block String

Line breaks / multiple lines allowed

s1 string = """
            """
s2 string = """
            Hello world
            """
s3 string = """
            Hello
            world
            """
s4 string = """
            It cost me $10.
            """
s5 string = """
            c:\Temp\Readme.txt
            """
s6 string = """
            <element attribute="value">Text</element>
            """
s7 string = """
            <html>
              <body class="main">
                <h1>Hello world</h1>
                <p>It cost me $10.</p>
              </body>
            </html>
            """

Escaped triple quote

s8 string = """
            def my_function():
              """""" This function will
                     print hello world """"""
              print("Hello world") 
            """

Interpolation

Interpolated String

Templating

x int = 100
y int = 200
istr string = $"The sum of $x + $y is $(x+y)"

Interpolated Block String

title string = "Hello world"
s string = $"""
           <html>
             <body class="main">
               <h1>$title</h1>
               <p>It cost me $$10.</p>
             </body>
           </html>
           """

Immutability

Null

null

n1 Object?
n2 Object? = null
n3 int?
n4 int? = null