ROR开发小技巧
2011年12月25日ruby-1.9.2-p180 :055 > File.join("lib/","ruby","gem.rb")
=> "lib/ruby/gem.rb"
ruby-1.9.2-p180 :058 > [1,2,3] - [1,2]
=> [3]
ruby-1.9.2-p180 :059 > [1,2,3] & [1,2]
=> [1, 2]
ruby-1.9.2-p180 :060 > [1,2,3] + [1,2,3,4]
=> [1, 2, 3, 1, 2, 3, 4]
ruby-1.9.2-p180 :066 > %w(a d c d 1 2 3)
=> ["a", "d", "c", "d", "1", "2", "3"]
ruby-1.9.2-p180 :074 > Hash["a",1,"b",2]
=> {"a"=>1, "b"=>2}
ruby-1.9.2-p180 :075 > Hash[*["a",1,"b",2]]
=> {"a"=>1, "b"=>2}
ruby-1.9.2-p180 :075 > Array("a".."z").select.with_index {|x,i| i%3 == 2}
=> ["c", "f", "i", "l", "o", "r", "u", "x"]
# coding:utf-8 # unicode转义 "" << 0x6f22 #=> 漢
class Object
# returns instance methods of current object's class and its singleton methods
def lm # abbr of local methods
self.methods.sort - self.class.superclass.instance_methods
end
end参考:http://ruby-china.org/topics/541
Comments
Bianca :
I can already tell that's gonna be super hpeflul.
2012年04月21日
GolfFoete :
Some of these factors can include the soil type and pH on your land to shade conditions, and the slope of the lawn area. <a href=http://lopolikumieo.com>cocksureness</a> Stuck on synonyms? http://lopolikumieo.com They can be paired with almost anything. <
2012年03月26日