單引號與雙引號的差別: 與shell中類似, 單引號中的內容不會被轉義, 雙引號中的內容會被轉義. 測試代碼如下:
name='butnet'
puts 'hello \t #{name}'
puts "hello \t #{name}"
=begin
輸出結果:
hello \t #{name}
hello butnet
=end
類初始化方法名: initialize
創建類的內容使用類的 new方法
class Test
def initialize
puts 'initialize'
end
end
a = Test.new
=begin
initialize
=end
ruby的多行註釋以=begin開始, 以=end結束, 單行註釋使用 井號 "#"