---
title: "Ruby学习笔记(一)"
author: "butnet"
date: "2011-12-08T11:32:46Z"
tags: []
categories: ["编程语言"]
slug: "ruby"
draft: false
lastmod: "2011-12-08T11:32:46Z"
id: 1297508
url: "https://butnet.iteye.com/blog/1297508"
---

单引号与双引号的差别: 与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结束, 单行注释使用 井号 "#"