TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

Ruby style guide

30 点作者 r11t大约 16 年前

5 条评论

masonlee大约 16 年前
Hm. Use one letter variable names for scoped variables? Excerpt from lines 92-112:<p>"* The length of an identifier determines its scope. Use one-letter variables for short block/method parameters, according to this scheme:<p><pre><code> a,b,c: any object d: directory names e: elements of an Enumerable ex: rescued exceptions f: files and file names i,j: indexes k: the key part of a hash entry m: methods o: any object r: return values of short methods s: strings v: any value v: the value part of a hash entry x,y,z: numbers And in general, the first letter of the class name if all objects are of that type."</code></pre>
评论 #561286 未加载
azanar大约 16 年前
<i>Do not program defensively. (See <a href="http://www.erlang.se/doc/programming_rules.shtml#HDR11." rel="nofollow">http://www.erlang.se/doc/programming_rules.shtml#HDR11.</a>) </i><p>I cross-referenced to the Erlang documentation, and they provided no other real justification for this rule, other than to say that the burden lies on the caller. Is there a history behind this convention? Is there a considerable benefit, other than more stream-lined code, to coding this way?
评论 #561277 未加载
评论 #561242 未加载
swombat大约 16 年前
I'm not quite sure why this style guide is more noteworthy than all the other ruby style guides out there.. e.g.:<p><a href="http://www.caliban.org/ruby/rubyguide.shtml" rel="nofollow">http://www.caliban.org/ruby/rubyguide.shtml</a><p>and<p><a href="http://www.pathf.com/blogs/2008/10/elements-of-ruby-style/" rel="nofollow">http://www.pathf.com/blogs/2008/10/elements-of-ruby-style/</a>
评论 #561061 未加载
wildjim大约 16 年前
I really hate other people's style-guides. Most of it is common-sense, but there's always some aspect or another that <i>really</i> grates against my preferences, e.g. "Keep lines fewer than 80 characters" is a pet hate; when did we return to Green-screen terminals?? My current company enforces this, and it often creates worse multi-line dischord cf. adding an extra 10 to 20 char's to the current line.<p>And "Read other style guides and apply the parts that don't dissent with this list" is a little too arrogant for <i>any</i> coder in the entire world -- perhaps should be "Replace any parts of this list that don't conform to your style".
评论 #561472 未加载
bazookaaa大约 16 年前
This is the second time in the past few days I've been told to use two spaces instead of tabs. Can anyone provide any insight as to what difference this makes?
评论 #561058 未加载
评论 #561065 未加载