class Greeter def initialize &block if block @block = block else @block = proc { |name| "Hello #{name}!" } end end def greet name = nil name = 'world' unless name @block.call name end end greeter = Greeter.new puts greeter.greet greeter = Greeter.new do |name| "Hi #{name}" end puts greeter.greet('John')