Create new method dynamically
class StringFactory
def StringFactory.method_missing(m, *args)
return String.new(m.to_s, *args)
end
end
puts StringFactory.a_string # => "a_string"
puts StringFactory.another_string # => "another_string"
Related examples in the same category