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

科技回声

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

GitHubTwitter

首页

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

资源链接

HackerNews API原版 HackerNewsNext.js

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

New Features in Ruby 2.4

222 点作者 jbackus将近 9 年前

12 条评论

saghm将近 9 年前
Some of these are pretty amazing, like the `digits` method and the new OptionParser functionality (which seems to be a sort of standard library equivalent to doctopt!).<p>That being said, I can&#x27;t help but shake my head at the section about &quot;multiple assignment of conditionals:<p>&quot;You can now assign multiple variables within a conditional...You probably shouldn’t do that though.&quot;<p>Am I alone and thinking that it&#x27;s a little bit hypocritical to specifically add functionality to your language if you don&#x27;t want people to use it? Or is this just a joke that&#x27;s gone over my head?
评论 #12135578 未加载
评论 #12135277 未加载
评论 #12135615 未加载
评论 #12136136 未加载
评论 #12135261 未加载
评论 #12135266 未加载
评论 #12136447 未加载
windor将近 9 年前
Ruby is the first language I really like. The core concept of the language is small, just not easy to get, but the change on how to programming is significant. Sadly, Ruby is not the language for the multi-core world, and many advantages of using it is disappearing. Although Ruby is changing, 2.3, 2.4, maybe 3.0, but what&#x27;s the difference?
评论 #12137530 未加载
评论 #12137070 未加载
评论 #12145907 未加载
评论 #12136460 未加载
评论 #12136023 未加载
评论 #12147321 未加载
评论 #12137071 未加载
jewbacca将近 9 年前
&gt; <i>If you are calling #sum on an array of non-integers then you need to provide your own initial value</i><p>Why? This doesn&#x27;t seem necessary, but, more importantly, would be inconsistent with #inject&#x27;s behaviour (if enforced).<p>----<p><a href="http:&#x2F;&#x2F;ruby-doc.org&#x2F;core-2.3.1&#x2F;Enumerable.html#method-i-inject" rel="nofollow">http:&#x2F;&#x2F;ruby-doc.org&#x2F;core-2.3.1&#x2F;Enumerable.html#method-i-inje...</a>:<p><i>If you do not explicitly specify an initial value for memo, then the first element of collection is used as the initial value of memo</i>
评论 #12135471 未加载
Olap84将近 9 年前
Will this be the last release before 3? Is there a defined schedule for 3 yet? Or just &quot;When it&#x27;s done&quot;?
评论 #12136326 未加载
ukoki将近 9 年前
digits method just saved code-golfers 20 characters.<p>`num.to_s.split(&#x2F;&#x2F;).map(&amp;:to_i)` =&gt; `num.digits`
评论 #12136368 未加载
评论 #12135506 未加载
mark_l_watson将近 9 年前
Great to see my favorite language evolving! I also use various lisps, Java, Haskell, Typescript, JavaScript, Python, etc., but I am happiest when coding in Ruby.<p>Unfortunately, most of what I do now is machine learning, and Python wrappers for underlying C++ code have by far more support than Ruby. (Ruby does have some great ML projects and libraries though).
评论 #12155576 未加载
评论 #12137269 未加载
sergiotapia将近 9 年前
Ruby 2.4 adds a new #match? method for regular expressions which is three times faster than any Regexp method in Ruby 2.3:<p>Why does Ruby have 4 different regexp match functions?<p>Regexp#match?: 2630002.5 i&#x2F;s Regexp#===: 872217.5 i&#x2F;s - 3.02x slower Regexp#=~: 859713.0 i&#x2F;s - 3.06x slower Regexp#match: 539361.3 i&#x2F;s - 4.88x slower
评论 #12135575 未加载
pmarreck将近 9 年前
Ruby continues to serve as a continuously fresh inspiration for Elixir. ;)
toolz将近 9 年前
Why do the old match operators now implicitly set a global variable? I feel like in a year I&#x27;m going to be debugging some really weird race conditions because of that change and I can&#x27;t see any value in it...if I want to use the value of a match operator I&#x27;ll _always_ save it to a local variable.<p>Can anyone shed any light on this, because my first attempts at grok&#x27;ing this change have me really blown away.
评论 #12137361 未加载
评论 #12137386 未加载
评论 #12139332 未加载
proyb2将近 9 年前
This code doesn&#x27;t make sense.<p><pre><code> 123.digits # =&gt; [3, 2, 1]</code></pre>
评论 #12135464 未加载
评论 #12137398 未加载
dkarapetyan将近 9 年前
These are all great but when are we getting optional typing? If the js ecosystem wasn&#x27;t a clown operation my language of choice would be typescript instead of ruby.
评论 #12136067 未加载
评论 #12137410 未加载
integrii将近 9 年前
Ruby syntax is just getting goofier and goofier.
评论 #12135317 未加载