代码审查(Code Review)一直是一个高效团队里面必备的流程,团队成员可以通过它达到技术交流,相互学习以及提升自身编码水平的目的。当然它的目的并不止于此,我们在做某一件事的过程中,所用的技能和工具不外乎都是为了能使结果更符合我们的期望,就拿建筑工程来说,质量控制就是其把控最严的一关,有专门的质量管理领导小组、质量组织管理体系制度来贯穿这个过程,其最终目的就是为了使这栋建筑坚固牢稳,避免随时有可能崩塌的危险。
字符串比较
Ruby中比较字符串是否相同也是用**==和!=**等运算符
1 | #whether two strings are equal |
如果是判断两字符串是否相似,采用正则表达式匹配更加简单。
1 | #whether two strings are similar |
字符串的创建
普通创建
Ruby中使用**” “或‘ ‘符号来创建字符串,在字符串中也可以包含表达式#{}**,这个表达式被称之为内嵌表达式。如果字符串中需要包含””或者’’等字符时,则可以通过转义字符\来实现。
1 | str = "this is a string" |
Octopress was broken after I upgraded Mac to OS X EI Capitan 10.11.1 in these days. The details of the problem is below.
Octopress is work well in Mac10.10. but when I upgraded to Mac10.11.1(OS X EI Capitan). And put rake preview in terminal to see the blog what looks like, got following error.
Starting to watch source with Jekyll and Compass. Starting Rack on port 4000
rake aborted!
Errno::ENOENT: No such file or directory - compass
/Users/user/git/octopress/Rakefile:85:in spawn
/Users/user/git/octopress/Rakefile:85:in block in <top (required)>
Tasks: TOP => preview
(See full trace by running task with --trace)
替换数组内的元素
根据指定规则替换数组中的元素,Ruby也提供了以下方法:
ary.collect { |item| …}
ary.collect! { |item| …}
ary.map { |item| …}
ary.map! { |item| …}
将数组ary中的各元素item传递给块做处理。
1 | ary = [1, 2, 3] |
Recently, I’ve encoutered a weird problem in the project, it’s about the value of the ngModel. Let me explain the problem. see the code
1 |
|
