2015年12月1日
摘要:
text = 'The rain in Spain falls mainly in the plain.'first = Hash.new []second = Hash.new {|hash,key| hash[key] = []}text.split(/\W+/).each do |word|...
阅读全文
posted @ 2015-12-01 21:44
c3tc3tc3t
阅读(423)
推荐(0)
2015年11月30日
摘要:
1获取字符串某部分s = "My kingdom for a string!"s.slice(3,7) # kingdoms[3,7] # kingdoms[/.ing/] # kings[/str.*/] # strings.slice(3).ord # 107
阅读全文
posted @ 2015-11-30 23:07
c3tc3tc3t
阅读(162)
推荐(0)
摘要:
1 单独处理字符串的字符如果处理的是ASCII码的文档使用string#each_byte注意 没有 string#each方法,String#each_byte 速度比 String#scan快 ,String#scan用于配合正则表达式时使用'foobar'.each_byte { |x| pu...
阅读全文
posted @ 2015-11-30 20:08
c3tc3tc3t
阅读(185)
推荐(0)
摘要:
ascii转字符或者字符串转ascii"a".ord # => 97"!".ord # => 33"\n".ord # => 10'a'[0] # => "a"'bad sound'[1] # => "a"'a'[0].ord # => 97'bad sound'[1].ord # => 9...
阅读全文
posted @ 2015-11-30 20:00
c3tc3tc3t
阅读(411)
推荐(0)
摘要:
在一个ruby字符串中包含表但是或者变量。想使用不同的值替换表达式或者变量1 类似java 或者python的printf-style方式template = 'Oceania has always been at war with %s.'template % 'Eurasia' # => "Oc...
阅读全文
posted @ 2015-11-30 14:00
c3tc3tc3t
阅读(191)
推荐(0)
摘要:
1 从一种数据结构中构件字符串hash = { key1: "val1", key2: "val2" }string = ""hash.each { |k,v| string "The number is 5.""The number is #{5}."# => "The number is 5....
阅读全文
posted @ 2015-11-30 13:25
c3tc3tc3t
阅读(361)
推荐(0)
2015年11月24日
摘要:
搜了一下原来缺少这个sudo apt-get install lib32z1 lib32ncurses5 lib32stdc++6
阅读全文
posted @ 2015-11-24 21:10
c3tc3tc3t
阅读(866)
推荐(0)
2015年11月19日
摘要:
http://lea.verou.me/demos/nth.html
阅读全文
posted @ 2015-11-19 21:27
c3tc3tc3t
阅读(223)
推荐(0)
2015年11月13日
摘要:
1 找到ruby执行文件目录$ wherris rubyruby: /usr/lib/ruby /home/rudy/.rbenv/shims/ruby2 设置软链接sudo ln -s /home/rudy/.rbenv/shims/ruby /usr/bin/ruby
阅读全文
posted @ 2015-11-13 15:18
c3tc3tc3t
阅读(236)
推荐(0)
2015年11月8日
摘要:
转自: http://www.cnblogs.com/elementstorm/archive/2013/04/10/3012679.htmlanon :true //匿名函数声明中function关键字与()之间的空白可以被省略bitwise : true //允许按位运算browser : ...
阅读全文
posted @ 2015-11-08 11:00
c3tc3tc3t
阅读(629)
推荐(0)