Comments
jhjguxin Published At

真的很不错,有时间 就可以在 wiki 里 淘一淘 多看看 改进自己的代码风格

juanito Published At

if n.zero? puts "Cannot divide by 0!" else

n / d

d.zero?

jhjguxin Published At

ruby # good if d.zero? puts "Cannot divide by 0!" else n / d end

Unknow user Published At

讲得挺细,嘻嘻

Crossle Published At
puts 'helloword'
Stone Published At

很有用,学习了!

longrm Published At

有些不是很赞成,既然 ruby 提供了多种语法,那为啥要强制使用某一种呢,岂不是画蛇添足了?

比如下面的:

bad

STATES = ['draft', 'open', 'closed']

good

STATES = %w(draft open closed)

yzhang Published At

好像这个已经不是推荐的用法了。rails 2.0 will deprecate it. (如果没有记错的话)。

lambda = ->(a, b) { a + b }

jacky_tzy Published At

代码应该具备自解释能力,这点不错!

ruby97 Published At

很赞

panlilu Published At

小标题的锚点链接有问题,请管理员检查一下

hustjackyan Published At

赞,非常不错

init5 Published At

非常感谢!

EvanYa Published At

字符串部分:有重复,感觉第二次的翻译有错 Consider padding string interpolation code with space. It more clearly sets the code apart from the string.考虑使用空格填充字符串插值。它更明确了除字符串的插值来源。

"#{ user.last_name }, #{ user.first_name }" Consider padding string interpolation code with space. It more clearly sets the code apart from the string. 考虑替字符串插值留白。這使插值在字符串里看起來更清楚。

"#{ user.last_name }, #{ user.first_name }"