mirror of
https://github.com/mruby/mruby
synced 2026-06-08 16:11:16 +00:00
Add proc composition feature (CRuby-2.6 compatible)
- Proc#<< and Proc#>> - Method#<< and Method#>>
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user