public
Last active

Overriding method by another defined in module - Ruby

  • Download Gist
gistfile1.rb
Ruby
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
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]"

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.