Skip to content

Instantly share code, notes, and snippets.

@jgaskins
Created June 26, 2013 22:43
Show Gist options
  • Save jgaskins/5872405 to your computer and use it in GitHub Desktop.
Save jgaskins/5872405 to your computer and use it in GitHub Desktop.
Fix initialize method-name typos once and for all.
class Class
# Important: keep 'initialize' at the end of this array
COMMON_INIT_MISSPELLINGS = %w(intitialize intialize initialise initialize) # etc...
def new(*args)
obj = allocate
obj.send COMMON_INIT_MISSPELLINGS.find { |m| obj.respond_to? m }, *args
obj
end
end
class Foo
def intialize
@bar = 'baz'
end
end
p Foo.new
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment