Ruby
LUCIEN06
这个作者很懒,什么都没留下…
展开
-
Ruby中单引号和双引号的区别
Ruby中使用引号括起字符表示字符串,但单引号和双引号有所不同。1. 单引号所括的内容不会做转义,直接就是字符串的内容。如: Ruby Code 1puts 'this is a test\n'结果为:2. 双引号中,Ruby会做更多事情。 首先Ruby会查找转义符‘\原创 2014-01-05 16:15:07 · 3246 阅读 · 0 评论 -
Ruby的time out机制
Ruby中的timeout机制是这样的:给timeout设置一个超时时限,若timeout后面的块内容执行时间超过了此时限,则引发异常,若没有超过此时限,则按原流程执行,相当于没有timeout。例如1 Ruby Code 12345678require 'timeout'begin time原创 2014-01-05 16:37:47 · 1420 阅读 · 0 评论 -
一些Ruby惯用法
1.%w(foo bar)or %w[foo bar] is a shortcut for ["foo", "bar"].Meaning it's a notation to write an array of strings separated by spaces instead of commas and without quotes around them. You can te原创 2014-01-27 16:52:58 · 648 阅读 · 0 评论 -
Ruby中通过require引用文件
转自: http://www.51testing.com/html/79/605679-851921.html一、引用单个文件:test目录下有两个文件file1.rb,file2.rb在file1.rb中: require 'file2'会报错,可以使用以下方法引用file2:1、require File.dirname(__FILE__)+'/file2'转载 2014-01-27 15:29:44 · 2402 阅读 · 0 评论