现在是2008-12-05 18:03:59,查看已提交项目、已收录的Blogs或者公司信息
请登录添加新项目、加入项目、点评别人的项目,或者 新注册? 提交Bug反馈.
iTechTag beta..
技能声望创造无限价值..
Understanding Ruby blocks, Procs and methods
该文章被关注了358次,收藏了0次,顶了0次 ,踩了0脚.
Ruby中的blocks, Procs 和 methods很是博大精深,我至今不得要领,每次看到文章,都想给大家分享。
刚才G.zhen.ning给我推荐了一篇文章,写的很不错,建议大家看看,地址如下:
http://eli.thegreenplace.net/2006/04/18/understanding-ruby-blocks-procs-and-methods
Ruby provides the programmer with a set of very powerful features borrowed from the domain of functional programming, namely closures, high-order functions and first-class functions [1]. These features are implemented in Ruby by means of code blocks, Proc objects and methods (that are also objects) – concepts that are closely related and yet differ in subtle ways. In fact I found myself quite confused about this topic, having a difficulty to understand the difference between blocks, procs and methods and unsure about the best practices of using them. Additionally, having some background in Lisp and years of Perl experience, I was unsure of how the Ruby concepts map to similar idioms from other programming languages, like Lisp’s functions and Perl’s subroutines. Sifting through hundreds of newsgroup posts, I saw that I’m not the only one with this problem, and in fact quite a lot of “Ruby Nubies” struggle with the same ideas.
In this article I lay out my understanding of this facet of Ruby, which comes as a result of extensive research of Ruby books, documentation and comp.lang.ruby, in sincere hope that other people will find it useful as well.
另外,技能云以前也有一篇文章Proc.new vs Lambda in Ruby 供参考。
标签: ruby, blocks, Procs, methods发布时间: 2008-01-23 11:28:02 | 发布者: IceskYsl | 阅读次数:358 回到主页
登录发表你对这个话题的看法吧?
圈子名称: Ruby社区
Ruby社区热门话题
-
Ruby的图书越来越多了
很早前,还记得最为经典的一副图片是两本Ruby和Rails的图书VS了Java的一大堆图书,让人觉得Ruby那个强...
-
Rio - Ruby I/O ...
发现一个相当棒的类库"Rio":http://rio.rubyforge.org/ ,使用了下,相当棒,特别推荐。...
-
急香港网页设计广告公司招聘兼職...
《 Homepage HongKong Communications Limited 》 招聘要求:急需开发一个...
-
Ruby 1.9.0 发布
Matz 发布了 Ruby 1.9.0 的开发版本。 你可以从这里得到: ftp://ftp.ruby...
-
Ruby::Net::HTTP...
一个 net/https 库的安全隐患被发现了。 详细信息见"原建议地址":http://www.isecp...
-
rubyconf 2007 t...
提供大会录像和网络服务的"Confreaks公司":http://www.confreaks.com/ 最近发布了...
-
镐头书第三版beta
!http://www.pragprog.com/images/covers/190x228/betas/ruby...
-
Proc.new vs Lam...
一直都不是很能把ruby的*Proc*运用自如,今天看一个gem的时候,又发现另外一个比较让我迷惑的东西*Lamb...
-
FXRuby: Create ...
!http://www.pragprog.com/images/covers/190x228/betas/fxru...
-
[下载]Humble Litt...
发现一本新的Ruby书籍"Humble Little Ruby Book ":http://www.hum...
最新话题
-
这个网站挺漂亮
很漂亮,风格不错。
-
用Java实现.net的Dat...
google coder地址:http://code.google.com/p/javadatatabledata...
-
用Java实现.net的Xml...
直接可以将用.net写好的操作xml的代码拿到java上面来运行,类名都保持一致的。 下载地址为:http:...
-
为什么项目中使用的技能不能修改?
为什么项目中使用的技能不能修改? 我写错了,没想到不能改了
-
Shanghai on Rai...
Shanghai on Rails 线下活动 - 7月26号(暂定) *活动时间及地点* 日期:08年7月...