Ruby - Functional Patterns in Ruby
What will be the output of the following Ruby code?
class Box
def initialize(value)
@value = value
end
def add(x)
@value += x
self
end
def multiply(x)
@value *= x
self
end
def value
@value
end
end
box = Box.new(2)
result = box.add(3).multiply(4).value
puts result