Created
May 10, 2011 02:28
-
-
Save kaos12/963819 to your computer and use it in GitHub Desktop.
Overriding method by another defined in module - Ruby
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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