Dear all : 今天碰到一个问题,不知道这个在ORACLE中的语法是怎样的。 请各位帮忙 在informix中该语句没有问题 select ..... from .... where ima01 matches ..[0-9][0-9][0-9]... 一般碰到matches '[YN]'之类的,我在oracle中用 .... in ('Y','N') 就OK了 还有碰到 matches '1*',我在oracle中用 .... like '1%' 就OK了 但是现在有好几个[]之类的,不...
by carrierye - Informix - 2009-12-25 13:41:01 阅读(5611) 回复(2)
? 和 ! 在ruby方法中意思 ?返回值的方法,如是不是在一个数组中[code]a=Array.new a<<2 a<<3 a<<4 a.include? 3 a.include? 6[/code]! 带这个符号的表示是会修改原来的对象[code]irb(main):012:0> a<<0 => [1, 2, 3, 4, 0] irb(main):013:0> a.sort => [0, 1, 2, 3, 4] irb(main):014:0> p a [1, 2, 3, 4, 0] => nil irb(main):015:0> a.sort! => [0, 1, 2, 3, 4] irb(main):016:0> p a [0, 1, 2, 3, 4] => nil irb(main):017:0> ...
ruby中的Mixin 当我们谈到继承,我们通常会分开为接口继承和实现继承。如果是单继承,无论是实现继承还是接口继承,都容易理解和使用。即便如此,在C++的著作中,还是提到当我们在继承一个类的时候,不仅仅要想到继承了实现,还要想到一并继承了接口。 多继承更是复杂,很容易走到菱形继承这样一个怪圈。在C#中,只有接口的多继承,并没有实现的多继承——我们不可以指定两个或两个以后的类作为父类。 ruby中的Mixin...
本帖最后由 wuliqingyt 于 2010-11-14 15:14 编辑
我用
find /root/source/ -name "*.h" -o -name "*.c" -o -name "*.cpp" > cscope.files
cscope -bkq -i cscope.files
命令生成
cscope.in.out, cscope.out, cscope.po.out三个文件
进入vim后
用cs s显示
# pid database name prepend path
0 10828 cscope.out
ruby 中获取目录大小 当前 Chito 中统计目录大小完全是偷懒的方式:[code]1. class Dir 2. def self.size(dir) 3. `du -s #{dir} | awk '{print $1}'`.to_i 4. end 5. end[/code]直接调用 du 这个程序然后把结果转换成数值就可以了,非常方便~ 不过要是运行在 Windows 下就不灵了,只好自己写代码统计下:[code]1. class Dir 2. def self.size(dir) 3. sum = 0 4. ...
本帖最后由 shijiang1130 于 2013-07-19 21:32 编辑 使用 Symbol 正如前边提到的, ruby 内部一直在使用 Symbol ,比如 ruby 程序中的各种名字,Symbol本质上是 ruby 符号表中的东西。使用 Symbol 处理名字可以降低 ruby 内存消耗,提高执行速度,这点我们在下一篇文章中会看到。 那么 Symbol 对我们有什么用呢?当然也是内存。使用 String 的开销太大了,因为每一个String 都是一个对象。想想前边的例子,一个字符串每出现一次...
ruby array中找出重复元素 ruby代码[code]1.#上文的inject现在用上了 2.module Enumerable 3. def dups 4. inject({}) {|h,v| h[v]=h[v].to_i+1; h}.reject{|k,v| v==1}.keys 5. end 6.end [/code]ruby代码[code]1.arr = %w{foo bar baz bar baz qux foo zub} 2.puts arr.dups.inspect 3.# => ["baz", "foo", "bar"] [/code]ruby代码[code]1.#替换一 2.inject(Hash.new(0)) {|h,v| h[v] += 1;...
ruby中require、load和include区别 ruby中,可以使用load和require来包含另一个文件。每次运行到load时,load后的文件会被载入并执行。 ruby代码[code]1.4.times do |i| 2. File.open("temp.rb","w") do |f| 3. f.puts "def test" 4. f.puts "#{i}" 5. f.puts "end" 6. end 7. load "temp.rb" 8. puts test 9.end 4.times do...
ruby 中 关于 yield 的用法 谁能给讲一下? 如何去理解 yield ? def fibUpTo(max) i1,i2=1,1 #parallel assignment while i1<=max yield i1 i1, i2 =i2,i1+i2 end end fibUpTo(1000){|f| print f," "}
ruby代码块中的return 看代码 ruby代码[code]def hello 1.times do |i| return 100 end 1000 end puts hello[/code]结果打印出来的是100,而不是1000 也就是代码块中的return 不止使用语句从迭代器中的代码块返回,而且使语句从返回到hello方法的调用