内容简介:翻译自:https://stackoverflow.com/questions/1751186/impressing-ruby-example
我强烈建议使用.each,.inject和/或.collect.例如:
# Sum 1,3,5,7,9,11,13
[1,3,5,7,11,13].inject { |a,b| a+b }
要么
# Print out all of the files in a directory
Dir.glob('./my_cool_directory/*').each do |file|
puts file
end
要么
# Find the length of all of the strings
["test", "hello there", "how's life today?"].collect{ |string| string.length }
翻译自:https://stackoverflow.com/questions/1751186/impressing-ruby-example
以上就是本文的全部内容,希望本文的内容对大家的学习或者工作能带来一定的帮助,也希望大家多多支持 码农网
猜你喜欢:- springCloud/印象
- 【iOS印象】GLPubSub 源码阅读笔记
- 浅谈 记一次 import 打包 印象误区
- 苹果WWDC印象:凶残的节奏、低调亮剑AI
- 服务通知:印象笔记PC端Markdown取消支持HTML标签解析功能
- 消除NLP中的刻板印象:程序员之于男性=家政人员之于女性?
本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们。
High Performance Python
Andrew Lewis / O'Reilly Media, Inc. / 2010-09-15 / USD 34.99
Chapter 1. Introduction Section 1.1. The High Performance Buzz-word Chapter 2. The Theory of Computation Section 2.1. Introduction Section 2.2. Problems Section 2.3. Models of Computati......一起来看看 《High Performance Python》 这本书的介绍吧!