文章列表
Secondly,write a delegator in another way
1.Code a class extends DelegateClass,and set a parameter that you want to use
2.Implementing your method initialize ,and donot forget to write super method.
3.Implementing your method which match to a parameter before you passed
4.And now,let's code
require ' ...
- 2006-10-30 14:43
- 浏览 1464
- 评论(0)
First of all, use SimpleDelegator class
1.first new a class
2.new another class extends SimpleDelegator,and donot forget require "delegate" at top of file
3.in this subclass ,super(obj) should be added in end of method initialize
4.let's look at code
require 'delegate'
class Hello
...
- 2006-10-30 14:38
- 浏览 1329
- 评论(0)
原文出处:
http://www.regular-expressions.info/ruby.html
在Ruby中使用正则表达式
Ruby支持正则表达式作为其一项语言特性。在Ruby中,正则表达式被写作 /模版/修饰符 的形式,这里的"模版"就是正则表达式本身,而"修饰符"则是一系列不同选项字符的标识,另外,"修饰符"部分是可选的。这个语法特点从Perl借鉴而来。
Ruby支持如下的修饰符:
/i 使正则表达式大小写不敏感(正则表达式本身是大小写敏感的)
/m 使"."匹配新行。Ruby使用/m,然而Perl和其 ...