From 9a9e12a1299181bc38abbb4e8dbb62569bcbc551 Mon Sep 17 00:00:00 2001 From: dearblue Date: Tue, 1 Jan 2019 13:15:48 +0900 Subject: Add proc composition feature (CRuby-2.6 compatible) - Proc#<< and Proc#>> - Method#<< and Method#>> --- mrbgems/mruby-proc-ext/mrblib/proc.rb | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'mrbgems/mruby-proc-ext') diff --git a/mrbgems/mruby-proc-ext/mrblib/proc.rb b/mrbgems/mruby-proc-ext/mrblib/proc.rb index 789b7a3ac..abe9c7944 100644 --- a/mrbgems/mruby-proc-ext/mrblib/proc.rb +++ b/mrbgems/mruby-proc-ext/mrblib/proc.rb @@ -39,4 +39,12 @@ class Proc make_curry.call end + def <<(other) + ->(*args, &block) { call(other.call(*args, &block)) } + end + + def >>(other) + ->(*args, &block) { other.call(call(*args, &block)) } + end + end -- cgit v1.2.3