
ruby
xianpeng2020
这个作者很懒,什么都没留下…
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
ruby 多继承 mixin include exclude require load
首先定义一个Module: module Foo def bar puts "foo"; end end 然后我们把这个模块混入到对象中去: class Demo include Foo end 如上编码后,模块中的实例方法就会被混入到对象中: d=Demo.new d.bar 会输出foo字样。 下面我们重新定义一下D转载 2014-05-02 11:25:07 · 763 阅读 · 0 评论 -
Ruby类方法 实例方法
ruby的类方法与实例方法 类方法也叫静态方法,通过类名来调用的方法。实例方法,必须要new一个实例出来才能用。 class Foo def self.bar puts 'class method' end def baz puts 'instance method' end end Foo.bar #class method #Foo.baz #报转载 2014-05-02 11:27:20 · 2232 阅读 · 0 评论 -
ruby安装
运行:sudo apt-get install ruby sudo apt-get update ruby 安装完成后,运行:ruby -v,提示当前安装的版本是1.8 书上提到了irb是一个很好用的ruby交互环境,而且在开发过程中要不断查阅文档,于是就使用: sudo apt-get install irb sudo apt-g转载 2014-04-02 21:18:45 · 528 阅读 · 0 评论 -
ruby pass by reference
Q1: What happens when you assign a new variable str to a value of 'foo'? str = 'foo' str.object_id # => 2000 A: A label called str is created that points at the object 'foo', which for the state转载 2014-04-04 01:14:18 · 635 阅读 · 0 评论 -
ruby 一切都是对象
ruby中一切都是对象 ,变量名 都是引用, 函数是值原创 2014-04-06 19:44:22 · 711 阅读 · 0 评论 -
ruby 类变量 实例变量
ruby中的实例变量前面需要加@ 类变量钱原创 2014-04-26 11:22:07 · 614 阅读 · 0 评论