摘要: Ruby是一中动态语言,可以覆写现有方法和类 !require 把外部文件载入到当前的程序中。load 代码每次载入时都被重新处理被包含的搜索路径: $:是个数组 $:.each {|d| puts} 增加自己的路径:$:.push '/usr/local/' 程序库(library): 是指可被其他程序调用、且独立存在的例程集合。 阅读全文
posted @ 2012-11-25 17:09 Linux、Mongo、Php、Shell、Python、C 阅读(137) 评论(0) 推荐(0) 编辑
摘要: 1:数字与表达式 变量是对象的占位符或者是引用2:比较运算符:age = 10 puts "You are age too young" if age < 18 puts "You are age too young" unless age < 18 循环:5.times do puts "Test" end <=> 5.times {puts "Test"}#从1到5 将数字顺着滑道 传送给 number变量3:浮点数x = 3y = 3.6 x.to_f y.to_i4:常量大写字母开头 阅读全文
posted @ 2012-11-25 13:33 Linux、Mongo、Php、Shell、Python、C 阅读(318) 评论(0) 推荐(0) 编辑
摘要: 1:Ruby是个面向对象的编程语言,Ruby中一切皆为对象。2: 类的简单介绍classPetattr_accessor:name,:age,:gener #三个可访问的属性endpet = Pet.new #创建个对象 class Cat <Pet #继承 attr_accessor:length #新的属性 def bark #方法 puts "Woof!" endend 3:attr.class #获取attr的所属类的名称 Kernel 特殊的类 :irb(main):006:0> Kernel.instance_methods=> [" 阅读全文
posted @ 2012-11-25 11:27 Linux、Mongo、Php、Shell、Python、C 阅读(352) 评论(0) 推荐(0) 编辑