《Ruby类型转换》的相关内容
相关博客
extend&include与class method&instance method
module B
def test
puts "B"
end
end
class A
end
A.extend B
#test成为A的class method
module B
def test
puts "B"
end
end
class A
include B
end
#test成为A的instanc ...
by hideto 2007-08-30 浏览 (904) 回复 (3) 关键字:
当 Class attribute 遇见 inheritance
Ruby的类变量遇到继承的时候:
class F
@@a = 'f'
def foo
puts @@a
end
end
class A < F
@@a = 'a'
end
class B < F
@@a = 'b'
end
a = A.new
a.foo # ...
by dongbin 2007-08-29 浏览 (512) 回复 (0) 关键字:
父类与子类引用的问题
class A {
public void func1() {
System.out.println("A func1 is calling.");
}
&nbs ...
by GongWenJun 2007-08-16 浏览 (205) 回复 (0) 关键字: java
define accessor in method
ruby 代码
# main.rb
# 2007年8月8日
#
module A
def nothing
...
by 9esuLuciano 2007-08-15 浏览 (163) 回复 (0) 关键字:
将结果转化为字符串的存取器函数
class MyClass
class << self
def accessor_string(*args)
args.each do |name|
class_eval <<-B
def #{name}
@#{name}.to_s
end
...
by tangzy001 2008-01-05 浏览 (102) 回复 (0) 关键字:

