易截截图软件、单文件、免安装、纯绿色、仅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 on Rails(急!!!!!!在线等)

HTML code:

<%= link_to_if_authorized l(:field_search_title), {:controller => 'books', :action => 'search', :project_id => @project, :title => @title} %>
<%= text_field_tag 't ......

Ruby到底干吗的?

主要做哪个方面的?是编译型的么?
一门编程语言,不是编译型的

看看这里吧:
http://www.ruby-lang.org/en/

ruby是一门解释型的面向对象语言。最具代表的应用是rails---web快速开发框架
......

ruby操作文件

require 'app/configuration'
module RubyAMF
  module Configuration
    #set the service path used in all requests
    # RubyAMF::App::RequestStore.service_p ......

请问有没有人学习Ruby语言?

请问有没有人学习Ruby语言?
这个问题有什么意义?



肯定有

。。。。。。。。。。。。。。呵呵
这个可以有

啪啪地,
。。。有还是没有?

引用
这个问题有什么意义?
散分的意义的有!

哈哈, ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号