初学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
相关问答:
做了三年。NET了
当然。NET水平也很烂
想多学一些新的语言
这两天在学习RUBY
不知道将来有没有前途
RUBY前辈们,指点一二啊。
别这山看着那山高,其实它们只是你的一个工具,就象武林高手拿个树叶 ......
主要做哪个方面的?是编译型的么?
一门编程语言,不是编译型的
看看这里吧:
http://www.ruby-lang.org/en/
ruby是一门解释型的面向对象语言。最具代表的应用是rails---web快速开发框架
......
连接Mysql数据库的时候,老是报这个错误!不知道怎么回事
各位大大们,能否告知,感激不尽
另外,我在公司域中,可能会出现一些问题
NoMethodError in BookController#list
undefined met ......
require 'app/configuration'
module RubyAMF
module Configuration
#set the service path used in all requests
# RubyAMF::App::RequestStore.service_p ......
希望给大家提供一些新的思路.
我们在使用C编程时会遇到一个问题,比如头文件的一个函数包含在一个lib 中,但是
在实际连接中我们不知道它在哪个库中。也许可行的一种办法是直接上网查询某个
函数的依赖条件,这对 ......