[#3986] Re: Principle of least effort -- another Ruby virtue. — Andrew Hunt <andy@...>

> Principle of Least Effort.

14 messages 2000/07/14

[#4043] What are you using Ruby for? — Dave Thomas <Dave@...>

16 messages 2000/07/16

[#4139] Facilitating Ruby self-propagation with the rig-it autopolymorph application. — Conrad Schneiker <schneik@...>

Hi,

11 messages 2000/07/20

[ruby-talk:03828] Order of overwriting

From: Aleksi Niemel<aleksi.niemela@...>
Date: 2000-07-05 13:48:18 UTC
List: ruby-talk #3828
This works probably just as it should, but I'm just curious why I expect
declarations to overwrite each other in the order they're written, instead
of "whaa, we have a class declaration here, let's see if we have to include
any modules before defining new, possibly overwriting, methods"?

module Foo
	def foo
		super
		puts "foo"
	end
end

module Foo_update
	def foo
		super
		puts "foo update"
	end
end

class Zak
	def foo
		puts "zak"
	end
end

class Bar < Zak
	def foo
		super
		puts "bar"
	end
	include Foo
	include Foo_update
end

Bar.new.foo  
# expected output:
# zak
# bar
# foo
# foo update

# prints:
# zak
# foo
# foo update
# bar


	- Aleksi

In This Thread

Prev Next