Yesterday morning,When I read the 4.2.3 chapter of the ruby book named <Programming Ruby>,I couldn't understand the meaning of this chapter.I have been reading this book for 2 weeks,but I only read fifty pages.I thought of the speed was too slowly and it was waste of time,
then I bought a Chinese version of this book.
After I bought the Chinese book I know the meaning of 'Closure'.'Closure' is a new jargon which I had heard of a year ago.Although I know it,I didn't know what it means.The following is a example which is showed in <Programming Ruby>,but I don't know where I can use this new feature.
This blog might be finished yesterday afternoon,but it was delayed by other thing.I wrote this blog as soon as I came in my office on this morning.
After I bought the Chinese book I know the meaning of 'Closure'.'Closure' is a new jargon which I had heard of a year ago.Although I know it,I didn't know what it means.The following is a example which is showed in <Programming Ruby>,but I don't know where I can use this new feature.
ruby 代码
def n_times(thing) return lambda {|n| thing * n } end p1 = n_times(23) p1.call(3) ! 69 p1.call(4) ! 92 p2 = n_times("Hello ") p2.call(3) ! "Hello Hello Hello "
This blog might be finished yesterday afternoon,but it was delayed by other thing.I wrote this blog as soon as I came in my office on this morning.
本文讲述了作者在阅读《Programming Ruby》一书过程中对于Closure概念的理解历程。Closure作为一个新术语,在Ruby中有着重要的作用。通过对比英文版与中文版书籍的内容,作者最终掌握了Closure的概念,并给出了一个具体的Ruby代码示例。
985

被折叠的 条评论
为什么被折叠?



