Project

General

Profile

Feature #6284

Updated by nobu (Nobuyoshi Nakada) almost 2 years ago

=begin 
 It would be nice to be able to compose procs like functions in functional programming languages: 

 ```ruby 
 

     to_camel = :capitalize.to_proc 
 
     add_header = ->val {"Title: " + val} 

 

     format_as_title = add_header << to_camel << :strip 
 ``` 

 instead of: 

 ```ruby 
 

     format_as_title = lambda {|val| "Title: " + val.strip.capitalize } 
 ``` 

 


 It's pretty easy to implement in pure ruby: 

 ```ruby 
 

   class Proc 
   
     def << block 
     
       proc { |*args| self.call( block.to_proc.call(*args) ) } 
     end 
   end 
 end 
 ``` =end

Back