低语的星空

浅浅的风

导航

Ruby 1.9.2 中的一些注意事项

很早以前匆匆的接触过 Ruby 1.8 版本,最近安装了 1.9.2 打算玩一玩 Ruby on Rails 3。

遇到了一些问题,我会陆续放上来。 Rails 3 的变化还是比较大的,我会单独开贴写。

 

我没有接触 1.9.1因为 Rails 3 官方貌似不太喜欢这个版本,呵呵。

今天对 module 进行了一下测试,代码很简单:

 

 

module Demo
	def hello
		puts "Hello,world"
	end
end

 

测试程序代码:

 

require 'demo'
include Demo

hello

 

 

执行结果如图:

 

恩,和书里写的很不一样。

找不到模块,在程序开始添加一下代码则可以正确运行:

$: <<'.'


或者将 require 'demo' 改成 require './demo' 亦可,这说明默认模块搜索目录不包含当前目录。

 

到官方主页查询,发现如下说明:

About Ruby 1.9.2

Ruby 1.9.2 is mostly compatible with 1.9.1, except the following changes:

  • Many new methods
  • New socket API (enhanced IPv6 support)
  • New encodings
  • Random class that supports various random number generators
  • Time is reimplemented. There is no longer the year 2038 problem.
  • some regexp enhancements
  • $: no longer includes the current directory.
  • dl is reimplemented on top of libffi.
  • new psych library that wraps libyaml. You can use the library instead of syck.

绕了一圈~汗

posted on 2010-09-03 10:48  jamiezz  阅读(253)  评论(0编辑  收藏  举报