diff options
| author | dearblue <[email protected]> | 2019-01-01 13:15:48 +0900 |
|---|---|---|
| committer | dearblue <[email protected]> | 2019-01-03 18:16:26 +0900 |
| commit | 9a9e12a1299181bc38abbb4e8dbb62569bcbc551 (patch) | |
| tree | 7161d8b5deee0fabd161c5f7995feb09840201d5 /mrbgems/mruby-method | |
| parent | 3e59f25eef8faf2677071dfc1add7142e92549e7 (diff) | |
| download | mruby-9a9e12a1299181bc38abbb4e8dbb62569bcbc551.tar.gz mruby-9a9e12a1299181bc38abbb4e8dbb62569bcbc551.zip | |
Add proc composition feature (CRuby-2.6 compatible)
- Proc#<< and Proc#>>
- Method#<< and Method#>>
Diffstat (limited to 'mrbgems/mruby-method')
| -rw-r--r-- | mrbgems/mruby-method/mrblib/method.rb | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/mrbgems/mruby-method/mrblib/method.rb b/mrbgems/mruby-method/mrblib/method.rb index 5de0afdf7..f7cefa2e5 100644 --- a/mrbgems/mruby-method/mrblib/method.rb +++ b/mrbgems/mruby-method/mrblib/method.rb @@ -17,4 +17,12 @@ class Method def name @name end + + def <<(other) + ->(*args, &block) { call(other.call(*args, &block)) } + end + + def >>(other) + ->(*args, &block) { other.call(call(*args, &block)) } + end end |
