Ruby - Functional Patterns in Ruby
What is the output of this Ruby code combining OOP and functional style?
class Calculator
def initialize(value)
@value = value
end
def double
@value * 2
end
def apply(func)
func.call(@value)
end
end
calc = Calculator.new(5)
puts calc.double
puts calc.apply(->(x) { x + 3 })