Add proc composition feature (CRuby-2.6 compatible)

- Proc#<< and Proc#>>
  - Method#<< and Method#>>
This commit is contained in:
dearblue
2019-01-01 13:15:48 +09:00
parent 3e59f25eef
commit 9a9e12a129
2 changed files with 16 additions and 0 deletions
+8
View File
@@ -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
+8
View File
@@ -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