Skip to content

Instantly share code, notes, and snippets.

@jm
Created April 15, 2009 15:23
Show Gist options
  • Select an option

  • Save jm/95842 to your computer and use it in GitHub Desktop.

Select an option

Save jm/95842 to your computer and use it in GitHub Desktop.
def create_from_string(klass, string = "")
# like calling String.new or something because
# klass is a variable representing the class you passed in
klass.new(string)
end
x = create_from_string(String, "dude")
y = create_from_string(Regexp, "wat")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment