基本类型

类型初始化

# 常量以大写字母开头。

# 整数
number = 42
otherNumber = 37
maxInt = (2**(0.size * 8 -2) -1)
Mb = 1_048_576 # 常量

# 双精度浮点数
exp = 2.71828
billion = 1E+9

# 字符串
greeting = "Hello"

# 多行字符串
text1 = "this is some\n" + \
        "multiLine text"

text2 = """this is some
multiLine text"""

# 布尔值
sunIsStar = true
earthIsStar = false

# 字符 "A"
charA = 'A' # "\x41", 65.chr

# 元组 (Int, String)
one = [1, "one"]

puts "maxInt is #{maxInt}"
puts "billion is #{billion}"
puts "text1 is '#{text1}'"
puts "text2 is '#{text2}'"
puts "charA is '#{charA}'"
puts "one is #{one}"