I bought the Chinese version of Programming Ruby

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.
ruby 代码
 
  1. def n_times(thing)  
  2. return lambda {|n| thing * n }  
  3. end  
  4. p1 = n_times(23)  
  5. p1.call(3) ! 69  
  6. p1.call(4) ! 92  
  7. p2 = n_times("Hello ")  
  8. 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.

你可能感兴趣的:(Blog,Office,Ruby)