Class: J8::BiFunction

Inherits:
Object show all
Includes:
Common
Defined in:
lib/j8/bi_function.rb

Direct Known Subclasses

BinaryOperator

Instance Method Summary collapse

Methods included from Common

callable_from_proc, from_callable, from_callable_class, initialize, lambda?, make_lambda, raise_unless_lambda

Instance Method Details

#apply(o1, o2) ⇒ Object



7
8
9
# File 'lib/j8/bi_function.rb', line 7

def apply(o1, o2)
  @callable.call(o1, o2)
end

#then(after = nil, &block) ⇒ Object



11
12
13
14
15
# File 'lib/j8/bi_function.rb', line 11

def then(after = nil, &block)
  callable = from_callable(after, block)

  J8::BiFunction.new(->(o1, o2) { callable.apply(*apply(o1, o2)) })
end