Skip to content

Instantly share code, notes, and snippets.

@kaos12
Created May 10, 2011 02:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kaos12/963819 to your computer and use it in GitHub Desktop.
Save kaos12/963819 to your computer and use it in GitHub Desktop.
Overriding method by another defined in module - Ruby
C:\Users\kaos12>irb
irb(main):001:0> require 'date'
=> true
irb(main):002:0> module Foo; def next(a=:hi); a; end; end
=> nil
irb(main):003:0> class Date; include Foo; end
=> Date
irb(main):004:0> Date.new.next
=> #<Date: 1/2,0,2299161>
irb(main):005:0> Date.new.next(:world)
ArgumentError: wrong number of arguments (1 for 0)
from (irb):5:in `next'
from (irb):5
from :0
irb(main):006:0> RUBY_DESCRIPTION
=> "ruby 1.8.7 (2011-02-18 patchlevel 334) [i386-mingw32]"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment