孤独的猫

  博客园 :: 首页 :: 博问 :: 闪存 :: 新随笔 :: 联系 :: 订阅 订阅 :: 管理 ::

irb(main):005:0> [1,1,3,5] & [1,2,3]
=> [1, 3]
irb(main):006:0> [1,2,3] * 3
=> [1, 2, 3, 1, 2, 3, 1, 2, 3]
irb(main):007:0> [1,2,3 ] * "--"
=> "1--2--3"
irb(main):008:0> [1,1,2,2,3,3,4,5]-[1,2,4]
=> [3, 3, 5]
irb(main):009:0> [1,2] <<'c'<<'d'<<[3,4]
=> [1, 2, "c", "d", [3, 4]]
irb(main):010:0> ["a","a","c"] <=> ["a","b","c"]
=> -1
irb(main):011:0> [1,2,3,4,5,6] <=> [1,2]
=> 1
irb(main):012:0> a=["a","b","b","b","c"]
=> ["a", "b", "b", "b", "c"]
irb(main):013:0> a.delete("b")
=> "b"
irb(main):014:0> a.delete("z")
=> nil
irb(main):015:0> a
=> ["a", "c"]

irb(main):016:0> a=["a","b","c"]
=> ["a", "b", "c"]
irb(main):017:0> a.clear
=> []
irb(main):018:0> ["a",nil,"b",nil].compact
=> ["a", "b"]
irb(main):019:0> ["a","b"].compact!
=> nil
irb(main):020:0> ["a","b"].concat(["c","d"])
=> ["a", "b", "c", "d"]



posted on 2012-03-28 20:30  孤独的猫  阅读(184)  评论(0编辑  收藏  举报