From: Rudolf Polzer Date: 2003-07-03T03:42:28+09:00 Subject: Re: Using & for arrays of objects Scripsit ille �Robert Klemme� : > "Joel VanderWerf" schrieb im Newsbeitrag news:3F013010.7030703@path.berkeley.edu... > > def i_think > > assert i_am # ;) > > end > > Hmmm... assert verifies that i_am is true, but Descartes concluded that > i_am must return true if i_think returns true. IMHO it's more like > > class Human > attr_accessor :thinks > def am; @thinks; end > end > > I = Human.new > I.am > I.thinks = true > I.am > > Note, that "I" is a constant which reflects our understanding of identity > quite good. Not really... that's not Ruby. In Ruby it would look like: class Beer def am?() is?() end def are?() is?() end end class Human < Beer def initialize() @thinking = false end def think!() @thinking = true end def drink!() @thinking = false end def thinking?() @thinking end def is?() return true if @thinking # ... other sufficient conditions for being ... # otherwise... false end end # BTW: it's a Be-er, that is, someone who *is*. No cervisia! i = Human.new() i.think!() p i.am?() -- class Heisenberg; def initialize(r, p) @r = r; @p = p; end; def r(); @p += 2 * rand() - 1; @r; end; def p(); @r += 2 * rand() - 1; @p; end; end; o = Heisenberg.new(17, 42); puts "impulse: %g, position: %g" % [o.p(), o.r()]; puts "impulse: %g, position: %g" % [o.p(), o.r()];