易截截图软件、单文件、免安装、纯绿色、仅160KB

初学ruby 怎么把一个类导入呢

1. 例如在

Person.rb 中 
Python code:

class Person
def talk
puts "nihao"
end

end




Student.rb
Python code:

class Student < Person
def talk
puts "nihao"
end

end


p = Student.new

p.talk




结果
>ruby Student.rb
Student.rb:1: uninitialized constant Person (NameError)
>Exit code: 1
 

经典 酷! book_simmone

自己添加require上去就行了~~~不过发现csdn ruby on rails 貌似人不多阿~~

不用那么麻烦的,在ruby中,include就可以实现继承
Python code:

class Student
include Person
def talk
puts "nihao"
end

end





相关问答:

ruby 要如何寫bnf

我是用netbeans 去寫bnf

a program will ONLY accept strings based on the following grammar:

            <compute> --> <value> = < ......

[已受理] 给Javascript和Ruby开个论坛专栏吧!

给Javascript和Ruby开个论坛专栏吧!
给Javascript和Ruby开个论坛专栏吧!
给Javascript和Ruby开个论坛专栏吧!
Javascript有专栏的:http://forum.csdn.net/SList/JavaScript

尊敬的用户deping_chen,您好: ......

初学ruby 怎么把一个类导入呢

1. 例如在
Person.rb 中 
Python code:

class Person
def talk
puts "nihao"
end

end
Student.rb
Python code:

class Student < Person
def talk
puts &quo ......

同时安装PHP和RUBY的问题 - Web 开发 / Ruby/Rails

学习PHP有一段时间了 现在想同时学习RUBY ON RAILS 
由于之前学习PHP 已经装好了APACHE 和 MYSQL 现在想让APACHE服务器也可以运行RUBY。
应该怎么办?
请高手提示 谢谢


Rails应用部署专栏: http://ww ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号