summaryrefslogtreecommitdiffhomepage
path: root/mrbgems/mruby-proc-ext/mrblib
diff options
context:
space:
mode:
authorYukihiro "Matz" Matsumoto <[email protected]>2019-01-04 14:32:19 +0900
committerGitHub <[email protected]>2019-01-04 14:32:19 +0900
commit2a9ccf24496429547c1280d6d0f18525cb20d1a9 (patch)
treedc798bb6c57c93a699b2b4aeea55835de7f1cd4c /mrbgems/mruby-proc-ext/mrblib
parentacb1fdc79fb1a18f843a49e8c7dd58a5610678c7 (diff)
parentfc20d0186dfa3a6bd72b4cf1e09a1497c50b536b (diff)
downloadmruby-2a9ccf24496429547c1280d6d0f18525cb20d1a9.tar.gz
mruby-2a9ccf24496429547c1280d6d0f18525cb20d1a9.zip
Merge pull request #4211 from dearblue/proc-composition
Add proc composition feature (CRuby-2.6 compatible)
Diffstat (limited to 'mrbgems/mruby-proc-ext/mrblib')
-rw-r--r--mrbgems/mruby-proc-ext/mrblib/proc.rb8
1 files changed, 8 insertions, 0 deletions
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